Skip to content

Instantly share code, notes, and snippets.

@capynet
Last active July 5, 2017 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capynet/6282268f1bee60368912 to your computer and use it in GitHub Desktop.
Save capynet/6282268f1bee60368912 to your computer and use it in GitHub Desktop.
Micro hammer.js adapter for jQuery
// Download http://hammerjs.github.io/
// jQuery plugin
(function ($) {
$.fn.mobileEvent = function (event, cb) {
this.length && (new Hammer(this.get(0)).on(event, $.proxy(cb, this)));
};
})(jQuery);
// Usage
$('.some-element').mobileEvent('tap', function (e) {
console.log(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment