Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hammerjs

hammerjs4.2mMIT2.0.8TypeScript support: definitely-typed

A javascript library for multi-touch gestures

touch, gestures

readme

Hammer.js 2.0.6

Build Status

Support, Questions, and Collaboration

Slack Status

Documentation

Visit hammerjs.github.io for detailed documentation.

// get a reference to an element
var stage = document.getElementById('stage');

// create a manager for that element
var mc = new Hammer.Manager(stage);

// create a recognizer
var Rotate = new Hammer.Rotate();

// add the recognizer
mc.add(Rotate);

// subscribe to events
mc.on('rotate', function(e) {
    // do something cool
    var rotation = Math.round(e.rotation);    
    stage.style.transform = 'rotate('+rotation+'deg)';
});

An advanced demo is available here: http://codepen.io/runspired/full/ZQBGWd/

Contributing

Read the contributing guidelines.

For PRs.

  • Use Angular Style commit messages
  • Rebase your PR branch when necessary
  • If you add a feature or fix a bug, please add or fix any necessary tests.
  • If a new feature, open a docs PR to go with.

Building

You can get the pre-build versions from the Hammer.js website, or do this by yourself running npm install -g grunt-cli && npm install && grunt build

changelog

Changelog

2.0.6, 2015-12-23

  • Add Assign method and deprecate merge and extend (#895fc01eae)
  • Expose Hammer on window or self if either is defined to avoid issues when AMD is present but not used. ( 356f795)
  • Add support for PointerEvent instead of MSPointerEvent if supported. (#754, 439c7a6)
  • Fixed moz-prefix, prefix should be Moz not moz. (3ea47f3)
  • Removed non-existant recognizer (f1c2d3b)
  • Fixed config leaking between instances(189098f)
  • Fixed gaps in gesture configs and update tests to match (70c2902)
  • Fixed Manager off method (#768, da49a27)
  • Added compatibility with requirejs optimizer namespaces ( 70075f2)
  • Made touchaction test zoomable ( 50264a7)
  • Fixed preventing default when for pan-x pan-y case ( 95eaafa)
  • Fixed incorrect touch action pan direction ( a81da57)
  • Fixed combined pan-x pan-y to resolve to none ( fdae07b)
  • Fixed inverted touch-action for pan recognizer (#728, 605bd3b)
  • Fixed dependency on non standard touch list ordering (#610, #791, 287720a)
  • Fixed swipe to not trigger after multitouch gesture (#640, 711d8a1)
  • Fixed swipe recognizer to use overall gesture direction and velocity ( 963fe69)
  • Fixed getDirection returning reversed direction ( e40dcde)
  • Fixed detection of tap when multi touch gestures are present ( c46cbba)
  • Fixed incorrect event order (#824, 92f2d76)
  • Fixed leaking options between recognizer instances (#813, af32c9b)
  • Fixed detection when element has no style attribute ( 5ca6d8c)

2.0.4, 2014-09-28

  • Fix IE pointer issue. #665
  • Fix multi-touch at different elements. #668
  • Added experimental single-user Touch input handler. This to improve performance/ux when only a single user has to be supported. Plans are to release 2.1 with this as default, and a settings to enable the multi-user handler.

2.0.3, 2014-09-10

  • Manager.set improvements.
  • Fix requireFailure() call in Manager.options.recognizers.
  • Make DIRECTION_ALL for pan and swipe gestures less blocking.
  • Fix Swipe recognizer threshold option.
  • Expose the Input classes.
  • Added the option inputClass to set the used input handler.

2.0.2, 2014-07-26

  • Improved mouse and pointer-events input, now able to move outside the window.
  • Added the export name (Hammer) as an argument to the wrapper.
  • Add the option experimental inputTarget to change the element that receives the events.
  • Improved performance when only one touch being active.
  • Fixed the jumping deltaXY bug when going from single to multi-touch.
  • Improved velocity calculations.

2.0.1, 2014-07-15

  • Fix issue when no document.body is available
  • Added pressup event for the press recognizer
  • Removed alternative for Object.create

2.0.0, 2014-07-11

  • Full rewrite of the library.