如果來(lái)回快速點(diǎn)擊下面的小圓點(diǎn),會(huì)出現(xiàn)偏移量出錯(cuò)的問(wèn)題,圖片會(huì)產(chǎn)生位移,不知道是算法的問(wèn)題還是瀏覽器的問(wèn)題。請(qǐng)老師指點(diǎn)下

慕粉5753041
2014-10-25
4 回答
舉報(bào)
0/150
提交
取消
2015-04-15
我覺得應(yīng)該吧if判斷放在最外層
for(var i=0;i<ospan.length;i++){
ospan[i].onclick=function(){
if(!animated){
if(this.className=='on'){
return;
}
for(var i=0;i<ospan.length;i++){
ospan[i].className='';
}
this.className='on';
var myIndex=parseInt(this.getAttribute('index'));
var offset=-600*(myIndex-index);
index=myIndex;
animate(offset);
}
}
}
2016-11-28
非常感謝,有用
2016-08-17
不對(duì)吧?? 我按你們說(shuō)的這么改也不對(duì)啊?? 反倒是源代碼里加 的 if (animated) { return;}這句比較有用
2015-05-21
老師寫錯(cuò)了,在那兩個(gè)onclick事件后面,寫if(!animated)是為了阻止整個(gè)onclick事件,但是老師只寫在事件里面的動(dòng)畫切換部分,動(dòng)畫切換雖然阻止了,但是小圓點(diǎn)的效果和index計(jì)數(shù)沒有被阻止;
如果把if(!animated),套在整個(gè)onclick事件里面的外層就行了;