Created
October 1, 2012 17:17
-
-
Save mkuklis/3813128 to your computer and use it in GitHub Desktop.
zepto click and tap events for mobile & desktop
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
if ('ontouchstart' in window) { | |
// turn off click event | |
$(document) | |
.on('click', 'a', function(e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
}) | |
.on('tap', 'a', function(e) { | |
window.location.href = $(e.currentTarget).attr('href'); | |
}); | |
} | |
else { | |
// delegate click to tap | |
$(document).on('click', 'a', function(e) { | |
$(e.currentTarget).trigger('tap'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment