jQuery 循环不恢复
我有 jquery 循环插件,并被要求在鼠标悬停时暂停它。不幸的是,我有一个透明图像悬停在整个幻灯片上(它是一个链接 - 单击幻灯片上的任意位置,然后转到其他地方),因此我设置了以下代码:
jQuery("#holder").mouseenter(
function(){
jQuery("ul.cycle").cycle("pause");
}
).mouseleave(
function(){
jQuery("ul.cycle").cycle("resume");
}
);
虽然这在我悬停一小会儿时有效,但如果我悬停的时间超过构造函数中指定的超时时间,然后系统不会重新启动。
我浏览过SO并发现这个邮政:
出现这个问题的原因是下一次迭代 假定要发生的转换是在完成之前设置的 之前的过渡。在某些情况下,下一次转换会在之前触发 前一个已经完成,新的过渡开始 每当已经有其他动画正在进行时就会进行检查 - 如果 所以,该函数只会返回并停止(无需设置下一个 迭代)。正在进行的动画结束后,幻灯片放映 已停止,因为没有安排下一次转换。
使用“暂停”后如何循环重新启动当前幻灯片的计时器?
I have got the jquery cycle plugin and have been asked to pause it on mouse hover. Unfortunately, I have a transparent image hovering over the entire slideshow (it's a link - click anywhere on slideshow and off you go somewhere else) so I have set up the following code:
jQuery("#holder").mouseenter(
function(){
jQuery("ul.cycle").cycle("pause");
}
).mouseleave(
function(){
jQuery("ul.cycle").cycle("resume");
}
);
While this works if I am hovering for a short moment, if I hover for more than the timeout period specified in my constructor then the system does not restart.
I have browsed SO and came across this post:
The reason why this problem has been occuring was that next iteration
where transition suppose to occure was setup before completion of
previous transition. In some cases, next transition was fired before
the previous has finished, at the beginning of that new transition
there's a check whenever there's already other animation going on - if
so, the function would just return and stop (without setting up next
iteration). After the ongoing animation was finished, the slideshow
was stopped, because there was no next transition scheduled.
How do I get cycle to restart the timer for the current slide after I have used 'pause'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经使用了@WTK在github上提供的修复: https://github.com/WTK/cycle
I have used the fix supplied by @WTK at github: https://github.com/WTK/cycle