Skip to content

Instantly share code, notes, and snippets.

@yeco
Forked from padolsey/gist:2521471
Created April 29, 2012 16:30
Show Gist options
  • Save yeco/2551711 to your computer and use it in GitHub Desktop.
Save yeco/2551711 to your computer and use it in GitHub Desktop.
Regular click event for touch devices [jQuery]
'createTouch' in document && (jQuery.event.special.click = {
setup: function(data, namespaces, eventHandle) {
var t;
$(this).bind('touchstart.touchClick', function() {
t = +new Date;
}).bind('touchend.touchClick', function(e) {
if (+new Date < t + 200) {
$(this).trigger('click', e);
}
})
},
teardown: function() {
$(this).unbind('.touchClick');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment