Chrome 标签页切换破坏了我的幻灯片放映
在这里,您可以找到我的幻灯片示例。 只要我们停留在页面上,幻灯片就可以很好地工作。图像每 5 秒淡出一次。它使用 jQuery Cycle Lite 插件。
当您切换到 Chrome 中的另一个选项卡时,就会出现该错误:例如,您等待大约 1 分钟,然后返回到幻灯片所在的选项卡。现在幻灯片有点停止了,我不知道为什么。 它只在 Chrome 中执行此操作,在 Firefox 或 Safari 中则不执行此操作(我尚未在 IE 中进行测试)。 更奇怪的是,它没有发生在 jQuery Cycle Plugin 主页上,你可以离开页面并返回,幻灯片仍然有效。
因此,如果有人知道该错误从何而来,请告诉我。
谢谢。
Here, you can find a sample of my slideshow.
The slideshow works great as long as we stay on the page. The images fade out every 5 seconds. It uses the jQuery Cycle Lite Plugin.
The bug appears when you switch to another tab in Chrome : you wait about 1 minute for example and go back to the tab where the slideshow is. Now the slideshow is kind of stopped and I don't know why.
It only does that in Chrome, not in Firefox or Safari (I didn't test in IE yet).
What is weirder, is that it didn't happen on the jQuery Cycle Plugin homepage, you can leave the page and go back and the slideshows are still working.
So if someone has any idea of where the bug come from, please let me know.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Chrome 显着增加了非活动选项卡的最小计时器延迟。也就是说,虽然活动选项卡可以运行间隔计时器(或普通超时计时器),最小延迟约为 10 或 15 毫秒,但对于非活动选项卡,最小延迟会增加到 1 秒左右。
这里是关于该问题的相关 Stackoverflow 问题,此处是另一个可能的解决方案。然而,当您有一个运行动画的插件时,可能需要修改该代码;可能取决于插件。
Chrome increases the minimum timer delay for inactive tabs, and by a significant amount. That is, while an active tab can run interval timers (or plain timeout timers) with a minimum delay of something like 10 or 15 milliseconds, for inactive tabs that minimum is increased to something like 1 second.
Here is a relevant Stackoverflow question on the issue, and here is another with a possible solution. When you've got a plugin that's running animations, however, it may require that that code be modified; depends on the plugin probably.
我想完成这次讨论。即使波蒂指出了问题的根源,但事实并非如此。在他给出答案后,我开始探索 jQuery Cycle 插件主页的代码,看看他们是如何解决这个问题的,但我没有找到任何东西。所以我复制粘贴了他们的部分代码,但幻灯片仍然无法正常工作。
所以我很生气,我也复制了 jquery 框架
script
标签,然后 tadaaaaaaa !!!看来jquery 1.6.1版本有问题。当我使用 1.5 版本时,效果很好。
I'd like to complete this discussion. Even if Pointy pointed out what seemed to be the source of the problem, it was not. After he gave his answer I started to explore the code of the jQuery Cycle Plugin homepage to see how they managed the problem but I didn't find anything. So I copied-pasted some part of their code, still nothing the slideshow was not working.
So I got angry and I copied the jquery framework
script
tag too and tadaaaaaaa !!!It seems there is a problem with the jquery version 1.6.1. When I use the 1.5 version it works great.