iOS 6 safari, setInterval doesn't get fired

依然范特西╮ 提交于 2019-11-30 07:30:15
jimp

iOS halts almost everything in response to user touch to guarantee it feels responsive. The setInterval issue is known, and there doesn't appear to be a workaround.

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

EDIT

During the "freeze" the timer will not catch up once the user releases the screen. The missed events are not deferred, but lost entirely (a bug).

Found this (scary but amazing) workaround, and it's working for me in iOS 6.0:

https://gist.github.com/3755461

I'm not completely sure, but you could use a setTimeout instead of setInterval? It's generally bad practice to use setInterval anyway.

var delay = 100;
(function callee() {
    setTimeout(callee, delay);
})();

iOS6 Safari suffers from a bug that kills timers that are created while a page is scrolling.

There is a fix to this problem provided by kTmnh by recreating timers after scrolling finishes

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!