gitwtfhub

wtf is hammer.js?

hammerjs/hammer.js — explained in plain English

Analysis updated 2026-06-21

24,359JavaScriptAudience · developerComplexity · 2/5Setup · easy

TL;DR

Hammer.js is a JavaScript library that detects touch gestures like swipes, taps, pinches, and presses on web pages, so you can build mobile-friendly interactions without writing complex low-level code.

Mindmap

mindmap
  root((hammer.js))
    What it does
      Detect touch gestures
      Handle raw events
      No dependencies
    Gestures
      Tap and double tap
      Swipe directions
      Pinch and rotate
      Press and hold
    Use Cases
      Mobile carousels
      Pinch to zoom
      Drag and drop
      Touch menus
    Tech Stack
      JavaScript
      Any web project

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Build a touch-driven image carousel that responds to left and right swipe gestures on mobile devices.

REASON 2

Add pinch-to-zoom functionality to a photo viewer in a web app.

REASON 3

Create a drag-and-drop interface that works correctly on both mouse and touchscreen devices.

REASON 4

Define a custom triple-tap gesture to trigger a hidden action in your web app.

What's in the stack?

JavaScript

How it stacks up

hammerjs/hammer.jsvercel/pkgwinstonjs/winston
Stars24,35924,37924,437
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min
License not mentioned in the explanation.

Wtf does this do

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.

Yoink these prompts

Prompt 1
Using Hammer.js, add swipe-left and swipe-right detection to a div element so I can build a mobile card-swipe interface in JavaScript.
Prompt 2
How do I use Hammer.js to enable pinch-to-zoom on an image element in a web page?
Prompt 3
I want to detect a press-and-hold gesture with Hammer.js and show a context menu after 500 milliseconds. How do I configure that recognizer?
Prompt 4
Show me how to define a custom recognizer in Hammer.js for a triple-tap gesture and run a JavaScript function when it fires.

Frequently asked questions

wtf is hammer.js?

Hammer.js is a JavaScript library that detects touch gestures like swipes, taps, pinches, and presses on web pages, so you can build mobile-friendly interactions without writing complex low-level code.

What language is hammer.js written in?

Mainly JavaScript. The stack also includes JavaScript.

What license does hammer.js use?

License not mentioned in the explanation.

How hard is hammer.js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is hammer.js for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.