Skip to content

Instantly share code, notes, and snippets.

@JasonMore
Created November 27, 2012 20:46
Show Gist options
  • Save JasonMore/4156895 to your computer and use it in GitHub Desktop.
Save JasonMore/4156895 to your computer and use it in GitHub Desktop.
fast click events on mobile web
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