Javascript animation stopped in ios Safari web browser browser when finger is on screen without lifting

I have a web view that is displayed in the application, there is animation on the page, a digital timer, where I show images of each digit, for example, 00:39, 29:39, etc.

it is animated using setInterval in javascript inside the page, the problem is that when I click on the screen, i.e. touching without raising the finger the browser stops, that is, the animation no longer animates, it stops in place when my finger touches the screen, and it will continue the animation after I raise my finger.

how can i fix this? I heard that I can use the default method by default, but would not ignore all my events on the page?

basicaly besides the timer on my webpage, I also have stuff that the user can interact with, so he is looking for a click event, etc.

so I definitely want to keep it please help

this happens on the ios device ... if I run in the desktop browser, everything looks fine .. doesn't stop watching

+6
source share
3 answers

found that problem. this has nothing to do with the ajax request or the processor, this is because a tiny scroll has been introduced. obviously all attempts will be stopped if you scroll or scroll.

0
source

Only for those who come across this later: Animation always stops in web browsers when scrolling , and this is what your web view expects with a finger. This will also happen in desktop browsers.

+1
source

Does it stop if you click anywhere or just on the counter? Try to prevent clicks on the counter element. For instance..

$('#counter-container').click(function() { e.preventDefault(); return false; }); 

Edit: Apparently, this is not uncommon. When iphone needs more CPU / memory resources, it will stop javascript execution. Look at using setInterval (runs javascript at a given interval before calling clearInterval ()) to determine if the animation has completed successfully.
Related questions:
User interaction sometimes wraps jQuery ajax requests in a UIWebView
Is AJAX constantly looking for a server update? Javascript
https://discussions.apple.com/thread/2723866?start=0&tstart=0

0
source

Source: https://habr.com/ru/post/914371/


All Articles