mootools/mootools-core — Issue #2123: Delayed click-events on touch devices
Author: pr3fect
Created: 2011-11-14 00:54:31+00:00
State: open

I recently saw someone reporting a mobile safari issue, where it has been said, that there is a certain delay when it comes to click-events.
So I checked this out on an iPad2 and really there is. If you tap multiple times too fast on one element, some click events just go missing as safari might expect some scrolling or 'doubletap-zoom' thing.

Now you can make use out of a combination of 'touchstart', 'touchmove' and 'touchend' to actually trap a 'tap' and fire your eventHandler. This works fast and it could enhance the responsiveness of a website/webapp. Though the problem with this is (out of my perspective), that you'd have to seperate between desktop-logic and touch-device-logic. I thought it'd be nice, if you could just write a good old Element.addEvent('click', function whatsoever(){}) without taking care of what device the user might be using and still benefit from those responsive techniques.

So i hacked a few lines of code, first to demonstrate the issue and second to provide a possible solution, that somewhat overloads the Element.addEvent method on touch devices (though I have no clue about that code about 'delegates' in the core. didnt see this in the docs either) and catches click eventHandlers to use the above technique.
I didn't know where else i could provide my code, so i just pasted all this in a jsfiddle here: http://jsfiddle.net/t8S9p/

Good/bad/dumb? You decide. Just let me know :)