hammerjs
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Hammer.js is a powerful JavaScript library primarily utilized for handling multi-touch gestures. With its robust and flexible framework, it offers developers an easy-to-use solution for managing touch, mouse, and pointerEvents. It's perfect for when you need to create a more interactive and seamless user experience on your web application or site, particularly on mobile or touch-enabled devices.
Using Hammer.js is straightforward and simple. Firstly, you will need to get a reference to an HTML element. With this reference, you can then create a manager for that element. Following this, you define a gesture recognizer - let's say for instance, a 'rotate' gesture. Once defined, you can then add this recognizer to the manager you created. Subsequently, subscribe to events on the manager to execute corresponding actions when these gestures are detected.
Here is a basic example:
// 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 gesture recognizer
var Rotate = new Hammer.Rotate();
// add the recognizer to the manager
mc.add(Rotate);
// subscribe to events on the manager
mc.on('rotate', function(e) {
// action to be executed when rotate event is detected
var rotation = Math.round(e.rotation);
stage.style.transform = 'rotate('+rotation+'deg)';
});
For a more advanced usage of the package, you can check out this demo.
For a comprehensive guide and detailed explanations of the capabilities of Hammer.js, you can visit the official documentation. Here, you will find all the information you need, from getting started, to using advanced features for creating complex touch-based interfaces.