admin管理员组文章数量:1333626
I would like to stop my jquery animation when I open new tab in browser. Every time when I leave my page for a while and I e back after some time, my jquery slider goes crazy and it change slides like insane, because I didn't stop it. Do you have some solution?
I would like to stop my jquery animation when I open new tab in browser. Every time when I leave my page for a while and I e back after some time, my jquery slider goes crazy and it change slides like insane, because I didn't stop it. Do you have some solution?
Share Improve this question asked Feb 12, 2012 at 1:40 user794596user794596 531 silver badge7 bronze badges 1- Please post a detailed example along with some relevant code. I know you already got your answer but this whole thing will be useless to future readers otherwise. – Sparky Commented Feb 12, 2012 at 2:53
2 Answers
Reset to default 8In JavaScript:
window.addEventListener('focus', function() {
// code to start
});
window.addEventListener('blur', function() {
// code to stop
});
With jQUery:
$(window).bind('focus', function() {
// code to start
});
$(window).bind('blur', function() {
// code to stop
});
I read somewhere about this and it's called animation queue buildup. Instead of trying to stop animation when opening new tab, put stop()
just before starting an animation.
This will ensure that previous animation is killed before continuing....
for example:
$('.some-selector').stop().slideUp();
Hope this helps...
本文标签: javascripthow to stop jquery animation when my page is not activeStack Overflow
版权声明:本文标题:javascript - how to stop jquery animation when my page is not active - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742348664a2458040.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论