Created
November 27, 2012 20:46
-
-
Save JasonMore/4156895 to your computer and use it in GitHub Desktop.
fast click events on mobile web
This file contains 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
this.bindTouchEvents = function (targetElement, touchEndFunction, context) { | |
var _context = context; | |
var moved = false; | |
$(document).off("touchstart", targetElement); | |
$(document).off("touchmove", targetElement); | |
$(document).off("touchend", targetElement); | |
$(document).on("touchstart", targetElement, null, function (event) { | |
}); | |
$(document).on("touchmove", targetElement, null, function (event) { | |
moved = true; | |
}); | |
$(document).on("touchend", targetElement, null, function (event) { | |
event.preventDefault(); | |
if (moved) { | |
} else { | |
_context[touchEndFunction](event); | |
} | |
moved = false; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment