Name: hammer.js
Owner: Hammer.js
Description: A javascript library for multi-touch gestures :// You can touch this
Created: 2012-03-02 12:58:28.0
Updated: 2018-01-20 13:08:32.0
Pushed: 2017-10-21 17:16:05.0
Homepage: http://hammerjs.github.io
Size: 10192
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A JavaScript library for detecting touch gestures.
install --save hammerjs
or
add hammerjs
or
https://cdnjs.com/libraries/hammer.js/
hammer.js has a quick start option for gestures it already recognizes.
et a reference to an element.
square = document.querySelector('.square');
reate an instance of Hammer with the reference.
hammer = new Hammer(square);
ubscribe to a quick start event: press, tap, or doubletap.
or a full list of quick start events, read the documentation.
er.on('press', function(e) {
target.classList.toggle('expand');
nsole.log("You're pressing me!");
nsole.log(e);
If you want to recognize your own gestures, such as tripletap
, then you'll have to use these steps:
et a reference to an element.
square = document.querySelector('.square');
reate a manager to manage the element.
manager = new Hammer.Manager(square);
reate a recognizer.
TripleTap = new Hammer.Tap({
ent: 'tripletap',
ps: 3
dd the recognizer to the manager.
ger.add(TripleTap);
ubscribe to the event.
ger.on('tripletap', function(e) {
target.classList.toggle('expand');
nsole.log("You're triple tapping me!");
nsole.log(e);
For further information regarding hammer.js, please read our documentation.
Feel encouraged to report issues or submit pull requests. When you're ready to do either, read our contribution guidelines. If you're looking for another form of contribution, we love help answering questions on our slack channel.