hammerjs/hammer.js

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

hammer.js NPM Version NPM Downloads Build Status

A JavaScript library for detecting touch gestures.

Installation
NPM
install --save hammerjs

or

Yarn
 add hammerjs

or

CDN

https://cdnjs.com/libraries/hammer.js/

Usage

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);

Examples
Documentation

For further information regarding hammer.js, please read our documentation.

Contributions Github Issues Github PRs Slack

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.

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.