暂停自动旋转(jQuery的)

问题描述:

我使用的是内容滑块插件是好的,但缺少一个重要的特征:确实鼠标悬停停止自动旋转滑片。暂停自动旋转(jQuery的)

下面是相关的部分从脚本:

var dotimer = function (x){ 
    if((opts.auto) == true) { 
     if(timer != null) 
      clearInterval(timer); 

     timer = setInterval(function() { 
       $(opts.next).click(); 
       }, 3000); 
    } 
} 

dotimer(); 

完整的脚本可以预览here

我想旋转暂停鼠标悬停和恢复上鼠标移开。

在此先感谢您的帮助!

找到了解决办法在这里:http://www.dlocc.com/articles/jflow-slider-auto-slider-with-pause-functionality/

还是要谢谢你。

您需要设置并清除计时器在hover事件:

var stopTimer() = function() { 
    if (!timer) return; 
    clearInterval(timer); 
    timer = false; 
}; 
$(something).hover(
    function() { stopTimer(); }, 
    function() { doTimer(); } 
); 

尝试:

$(opts.slides).hover(function() { 
    clearInterval(timer); 
}, 
function() { 
    dotimer(); 
});