Hammer.js adds recognizers for pan, swipe, tap, doubletap, and press on DOM elements. It targets webpages that need touch and pointer interaction beyond basic clicks.
Overview
Hammer.js is a client-side JavaScript library that listens for multi-touch and pointer gestures on web pages. You attach it to a DOM element and handle built-in gesture types such as pan, swipe, tap, doubletap, and press.
A simple setup uses a single Hammer instance on an element with defaults for those gestures. Hammer.Manager offers finer control when several recognizers must run together, compete, or depend on one another succeeding or failing.
You can install it as a package or load a pre-built script in the page. The distributable build is small when gzipped for production use.
Documentation covers installation, configuration, and recognizer behavior for teams integrating touch-driven interfaces in web applications.
Key features
- Pan, swipe, tap, and press recognizers
- Hammer.Manager for custom recognizer setups
- Attach listeners to any DOM element
- Package install or script include
- Pre-built minified production bundle
- Recognizer interaction and failure rules
Use cases
- Touch-friendly mobile web UIs
- Swipe-based navigation
- Custom tap and double-tap handling
- Draggable on-screen elements
- Games and interactive widgets in the browser