jQuery中stop无法停止delay,可以加一个无意义的动画代替delay;
如:$(...).animate({"null":1},等待时间,回调函数);
让所有动画在回调函数中执行。
原来的代码为:
autoMove:function(){ //自动轮播 var me=this; me.moved++; me.$ulImgs.delay(me.WAIT).animate({ left:-me.$LIWIDTH*me.moved },me.DURATION,function(){ if(me.moved==imgs.length){ me.$ulImgs.css("left",0); me.moved=0; } me.changeHover(); me.autoMove(); }); },
修改后为:
autoMove:function(){ //自动轮播 var me=this; me.moved++; me.$ulImgs.animate({"null":1},me.WAIT,function(){ me.$ulImgs.animate({ left:-me.$LIWIDTH*me.moved },me.DURATION,function(){ if(me.moved==imgs.length){ me.$ulImgs.css("left",0); me.moved=0; } me.changeHover(); me.autoMove(); }); }) },