Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hammerjs

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hammerjs

A javascript library for multi-touch gestures

  • 2.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
decreased by-19.39%
Maintainers
2
Weekly downloads
 
Created

What is hammerjs?

Hammer.js is a popular JavaScript library for handling touch gestures. It provides a simple way to recognize gestures made by touch, mouse, and pointer events, enabling developers to easily implement interactive features such as swiping, pinching, rotating, and pressing on web pages.

What are hammerjs's main functionalities?

Swipe Gesture

This code sample demonstrates how to detect left and right swipe gestures on an element. It initializes Hammer.js on a target element and listens for 'swipeleft' and 'swiperight' events.

var myElement = document.getElementById('myElement');
var mc = new Hammer(myElement);
mc.on('swipeleft swiperight', function(ev) {
    console.log(ev.type + " gesture detected.");
});

Pinch Gesture

This example shows how to enable and detect pinch gestures. It sets up pinch gesture recognition on an element and logs the scale of the pinch gesture.

var myElement = document.getElementById('myElement');
var mc = new Hammer(myElement);
mc.get('pinch').set({ enable: true });
mc.on('pinch', function(ev) {
    console.log("Pinch gesture detected with scale: " + ev.scale);
});

Rotate Gesture

This code snippet enables rotation gesture detection on an element. When a rotate gesture is detected, it logs the rotation angle.

var myElement = document.getElementById('myElement');
var mc = new Hammer(myElement);
mc.get('rotate').set({ enable: true });
mc.on('rotate', function(ev) {
    console.log("Rotate gesture detected with angle: " + ev.rotation);
});

Other packages similar to hammerjs

Keywords

FAQs

Package last updated on 22 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc