Last active
October 1, 2015 12:18
-
-
Save chrtze/c025bab67ce20dc21ba1 to your computer and use it in GitHub Desktop.
simple touch event fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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