Question

I have a standalone web application that used to work fine with iOS 6.

With iOS 7 I noticed that there is a significant delay (several seconds) in firing the javascript touchend event after a finger swipe. The behavior is not consistent, sometimes the first swipe generates the event immediately and only the following ones are delayed.

Is this a known issue and/or there is a workaround?

Thanks.

Was it helpful?

Solution

I was experiencing this same problem with an HTML5 game I'm developing. Sometimes the touchend would seem to fire immediately, and other times there would be a delay of several seconds before it fired.

I stumbled upon this post reminding me of the setTimeout 0 trick for pushing a block of javascript onto the queue for later processing. I was doing a bit of "heavy-lifting" (some DOM manipulation) inside the touchend event handler, and this appeared to disrupt its firing.

I wrapped the code inside my touchend handler with a setTimeout, and that eliminated the delay:

$(document).on('touchend', function (e) {
    setTimeout(function(){
        //do stuff here...
    }, 0);
});

OTHER TIPS

Safari on iOS 7 and HTML5: problems, changes and new APIs: http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review

iOS 7.1 seems to fix this issue; touchend events fire properly (even without the zero timeout)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top