The Changelog

Open Source moves fast. Keep up.

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.

Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.