Andrew Thorp changelog.com/posts

Hammer.js - Easily add multi-touch to your websites

With the continued growth of mobile devices, handling touch (and multi-touch) events is no longer optional. Hammer.js is a small - dependency free - library that makes handling touch events dead simple.

You can easily add tap (touch/click), double tap, hold, drag (touchmove/mousemove), swipe, and transform (pinch) events to your website with very little code. 

var hammer = new Hammer(document.getElementById("hammertime"));
hammer.ondoubletap = function(e){
  console.log("CAN touch this!");
};

Oh, and if jQuery is your thing, they have a simple plugin that you can download as well.

View the demo or browse the source on GitHub.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00