简体   繁体   English

在滚动期间,setInterval在iphone / ipad(移动版Safari)中暂停

[英]setInterval pauses in iphone/ipad (mobile Safari) during scrolling

I use the setInterval function in a website, and it works fine in IE, Chrome, Firefox and Safari. 我在网站中使用setInterval函数,它在IE,Chrome,Firefox和Safari中运行良好。 When i try it on ipad/iphone (safari mobile) i get problem: if i scroll the screen, the setInterval function pauses and it resumes only when i stop scrolling! 当我在ipad / iphone(safari mobile)上尝试时,我遇到问题:如果我滚动屏幕,setInterval函数暂停,只有当我停止滚动时它才会恢复!

is there a way to prevent the function from pausing? 有没有办法防止该功能暂停? Thanks 谢谢

I'm afraid no, there's no way to prevent such behaviour. 我不敢,没有办法阻止这种行为。 There's a plenty of topics here in SO about this problem (more-o-less related), here's a particularly interesting one . 这里有很多关于这个问题的主题(更多相关性),这是一个特别有趣的问题 Its summary is simple: 它的总结很简单:

iOS elastic scroll can't be tracked. iOS弹性滚动无法跟踪。 There's no event listener for it + both timeout / interval doesn't execute during scroll. 它没有事件监听器+滚动期间不执行超时/间隔。 And because there's no requestAnimationFrame in iOS5, this seems impossible to solve. 而且因为iOS5中没有requestAnimationFrame,所以这似乎无法解决。

iOS6 Safari suffers from a bug that kills timers that are created while a page is scrolling. iOS6 Safari遭受了一个错误,它会杀死页面滚动时创建的计时器。

There is a fix to this problem provided by kTmnh by recreating timers after scrolling finishes kTmnh通过在滚动完成后重新创建计时器来解决此问题

https://gist.github.com/3798925 . https://gist.github.com/3798925

检查@Pattishall关于这个主题的答案如果在其中有setTimeout,则不会调用iOS 6 js事件函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM