Skip to content
프로젝트

소개

멀티터치 제스처를 위한 JavaScript 라이브러리 :// You can touch this

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
-2
in 7 days
-2
in 15 days
-3
in 1 month
-8

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Hammer.js

CI npm version

A JavaScript library for multi-touch gestures.

Visit hammerjs.github.io for detailed documentation.

Installation

npm install hammerjs

Or download the pre-built bundle from GitHub Releases or load it from a CDN:

<script src="https://cdn.jsdelivr.net/npm/hammerjs/hammer.min.js"></script>

Usage

Create a Hammer instance on a DOM element to listen for the default gestures (pan, swipe, tap, doubletap, and press):

import Hammer from 'hammerjs';

const element = document.getElementById('my-element');
const mc = new Hammer(element);

mc.on('panleft panright tap press', (ev) => {
    console.log(ev.type + ' gesture detected.');
});

For full control over recognizers and how they interact (such as simultaneous gestures or requiring another gesture to fail), use Hammer.Manager:

const mc = new Hammer.Manager(element);

mc.add(new Hammer.Pan({ direction: Hammer.DIRECTION_ALL, threshold: 0 }));
mc.add(new Hammer.Tap({ event: 'doubletap', taps: 2 }));
mc.add(new Hammer.Tap());

mc.get('doubletap').recognizeWith('tap');
mc.get('tap').requireFailure('doubletap');

mc.on('doubletap', (ev) => {
    console.log('doubletap', ev);
});

mc.on('tap', (ev) => {
    console.log('tap', ev);
});

Building & Testing

Requires Node.js >= 22.

npm install
npm test       # runs ESLint and the QUnit suite in headless Chrome
npm run lint   # runs ESLint only
npm run build  # builds hammer.js, hammer.min.js, sourcemaps, and runs tests

Contributing

Read the contributing guidelines before opening an issue or pull request.

For pull requests:

  • Use Angular-style commit messages
  • Make changes in src/ and tests/ (do not commit rebuilt hammer.js / hammer.min.js bundles)
  • Add or update unit tests for any bug fix or behavior change
  • Run npm test to verify linting and all unit tests pass

For maintainers cutting a release, see RELEASING.md.

License

Licensed under the MIT License.

관련 프로젝트 살펴보기

불러오는 중…