Skip to content

Instantly share code, notes, and snippets.

@chrtze
Last active October 1, 2015 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrtze/c025bab67ce20dc21ba1 to your computer and use it in GitHub Desktop.
Save chrtze/c025bab67ce20dc21ba1 to your computer and use it in GitHub Desktop.
simple touch event fix
var hasMoved;
$(el).on('touchend touchstart touchmove', function(e) {
if(e.type == 'touchstart') {
hasMoved = false;
}
else if(e.type == 'touchmove') {
hasMoved = true;
}
else if(e.type == 'touchend') {
if(!hasMoved) {
e.stopPropagation();
e.preventDefault();
$(e.target).trigger('click');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment