首页 新闻 赞助 找找看

网站首页焦点图的问题

0
悬赏园豆:15 [已解决问题] 解决于 2013-07-11 12:58

最近遇到一个网站首页焦点图的问题:如果鼠标快速滑过图片上的数字标签,过一会儿图片的切换就会不再是匀速的了,而是变得时快时慢。(见http://www.fotosay.com/ 的每日精选)

---------------------

photoslider_index1.js如下

----

 1 // tab切换,c为ID名
 2 function tabswitch(c, config){
 3     this.config = config ? config : {start_delay:5000, delay:5000};
 4     this.container = $i(c);//获取id为c的元素
 5     this.pause = false;
 6     this.nexttb = 1;
 7     this.tabs = this.container.getElementsByTagName('dt');//在id为c的元素下寻找标签名为dt的元素
 8     var _this = this;
 9     if (this.tabs.length < 1) {// 如果没有dt,再找li
10         this.tabs = this.container.getElementsByTagName('li');
11     }
12 
13     for(var i = 0; i < this.tabs.length; i++){
14         var _ec = this.tabs[i].getElementsByTagName('span');// 在每个tab下寻找span标签
15         if(_ec.length<1)_ec = this.tabs[i].getElementsByTagName('a');// 如果没有span标签就找a标签
16         if(_ec.length<1){// 如果当前tab下无元素,则把当前tab赋给_ec
17             _ec = this.tabs[i]
18         }else{
19             _ec = _ec[0];// 有元素则取当前tab下第一个元素(span或a)
20         }
21 
22         // tab的鼠标悬浮事件
23         _ec.onmouseover = function (e) {
24             _this.pause = true; //暂停
25             var ev = !e ? window.event : e; //获得源事件
26             _this.start(ev, false, null); //启动            
27         };
28         
29         // tab的鼠标滑出事件
30         _ec.onmouseout = function() {
31             _this.pause = false; // 取消暂停        
32         };
33 
34     if ($i(c + '_sts')) {
35         var _sts = $i(c + '_sts');
36         var _step = _sts.getElementsByTagName('li'); // 获取 li
37         if (_step.length < 1) _step = _sts.getElementsByTagName('div'); // 如果没有li则获取div
38         _step[0].onclick = function() {//第一个元素点击事件
39             if (_this.tabs[_this.tabs.length-1].className.indexOf('current') > -1) {
40                 _this.nexttb = _this.tabs.length + 1;
41             };
42             _this.nexttb = _this.nexttb - 2 < 1 ? _this.tabs.length : _this.nexttb - 2;
43             _this.start(null, null, _this.nexttb);
44         };
45         
46         // 第二个元素点击事件
47         _step[1].onclick = function() {
48             _this.nexttb = _this.nexttb < 1 ? 1 : _this.nexttb; // nexttb小于1则取1
49             _this.start(null, null, _this.nexttb);
50         };
51     };
52     
53     // tab启动方法。
54     this.start = function(e, r, n){
55         if(_this.pause && !e)return;//暂停 无事件则返回
56         if(r){
57             curr_tab = $i(_this.container.id + '_' + rand(4));
58         }else{
59             if(n){
60                 curr_tab = $i(_this.container.id + '_' + _this.nexttb);// 当前tab向下变动
61             }else{
62                 curr_tab = _jsc.evt.gTar(e);
63                 if (curr_tab.id == "") curr_tab = curr_tab.parentNode;// 当前tab为空则当前tab父节点赋给当前curr_tab
64             }
65         }
66         
67         var tb = curr_tab.id.split("_");
68         for(var i = 0; i < _this.tabs.length; i++){
69             if(_this.tabs[i]==curr_tab){// 当前tab加上样式"cn6"
70                 _this.tabs[i].className="cn6";
71                 try{
72                     //alert(_this.tabs[i].id);
73                     $i(_this.tabs[i].id + '_body').style.display = "block";
74                 }catch(e){}
75             }else{// 非当前tab加样式"cn7"
76                 _this.tabs[i].className="cn7";
77                 try{
78                     $i(_this.tabs[i].id + '_body').style.display = "none";
79                 }catch(e){}
80             }
81         }
82         _this.nexttb = parseInt(tb[tb.length-1]) >= _this.tabs.length ? 1 : parseInt(tb[tb.length-1]) + 1;// nexttb赋值
83         setTimeout("banners.start(null, null, 1);", 2000);
84     };
85 }

麻烦各位高手看一下是甚么问题?

iplayfor的主页 iplayfor | 初学一级 | 园豆:175
提问于:2013-07-11 10:11
< >
分享
最佳答案
0

这么长的代码谁会去看。。。

你的那个图片切换插件有问题,如果鼠标在数字上快速来回滑动几次,图片就会自己不断的闪来闪去

建议下载一个别人写好的插件吧 这种东西到处都是

如果就是想自己完成,解决方案是

给图片的切换添加一个延时处理,例如 当光标在数字上悬浮0.2秒才切换图片

收获园豆:15
TiestoRay | 小虾三级 |园豆:687 | 2013-07-11 10:34

问题已解决,谢谢。

iplayfor | 园豆:175 (初学一级) | 2013-07-11 15:02
其他回答(1)
0

问题没解决可以到这里看看有没有你需要的幻灯片效果  http://www.100sucai.com/code/849.html

1565783227 | 园豆:227 (菜鸟二级) | 2014-08-18 12:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册