Tap Event
Make your touchstart
event listeners into a tap
event listener!
What is "correct" behavior? The tap
event:
- shouldn't be triggered until the user removes his/her finger from the surface of the screen.
- shouldn't be triggered when the user moves his/her finger at all (ie it should not interfere with drag events).
- shouldn't be triggered if there's ever more than a single finger on the surface at all.
- should never trigger the
click
event.
API
var tap = var el = document // the event you want to handle { // e.preventDefault() is already called! locationhref = thishref} // wrap the listenervar listener = // listen to `touchstart`el // remove the listenerel
or, more succinctly:
document
To set a custom timeout (default is 200ms
), you have two options:
// set globallytaptimeout = 300 // set per instance