Build touch-driven carousels and sliders that respond to swipe gestures on mobile devices.
Create pinch-to-zoom image viewers and map interfaces that scale content with two-finger gestures.
Implement drag-and-drop interfaces that feel native on tablets and phones.
Add custom gesture recognition like triple-tap or multi-finger swipes to web apps.
Hammer.js is a JavaScript library that makes it easy to detect touch and gesture interactions on web pages. Normally, tracking gestures like swipes, taps, pinches, or presses involves writing complicated low-level code to interpret raw touch events from the browser. Hammer.js handles all that complexity so you can simply say "when the user swipes left, do this" without worrying about the underlying mechanics. It works by attaching a listener to any HTML element on your page. You then subscribe to named gesture events, tap, double tap, press, swipe, and so on, and provide a function to run when that gesture is detected. For custom gestures not included by default, you can define your own recognizers with specific rules (for example, a triple tap). You would use this when building a web app that needs to feel native on mobile devices: touch-driven carousels, drag-and-drop interfaces, pinch-to-zoom image viewers, or any interactive experience where mouse clicks aren't enough. It is a pure JavaScript library with no framework dependency, so it works with any web project.
Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.