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

12,420

Solution 1

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. 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.

Solution 2

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.

Share:
12,420
Admin
Author by

Admin

Updated on June 14, 2022

Comments

  • Admin
    Admin almost 2 years

    I use the setInterval function in a website, and it works fine in IE, Chrome, Firefox and 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!

    is there a way to prevent the function from pausing? Thanks

  • Admin
    Admin almost 12 years
    i hope they will solve it in iOS 6, however thank you very much!
  • Niels Keurentjes
    Niels Keurentjes over 11 years
    This issue has not been resolved in iOS6 - all Javascript is simply paused during elastic scroll and not resumed until the scrolling stops (and onScroll is fired).
  • Tyler Biscoe
    Tyler Biscoe over 10 years
    Seems to be fixed in iOS 6.1