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

pan-zoom

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pan-zoom

Pan and zoom events for any element

  • 3.5.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

pan-zoom tiny unstable

Panning and zooming events for any target. May come handy for webgl, canvas, svg, images or pure html manipulations. Handles mobile pinch-zoom, drag and scroll interactions, provides inertial movement.

See demo.

npm install pan-zoom

const panzoom = require('pan-zoom');

let unpanzoom = panzoom(document.body, e => {
  // e contains all the params related to the interaction

  // pan deltas
  e.dx;
  e.dy;

  // zoom delta
  e.dz;

  // coordinates of the center
  e.x;
  e.y;

  // type of interaction: mouse, touch, keyboard
  e.type;

  // target element event is applied to
  e.target;

  // original element event started from
  e.srcElement;

  // initial coordinates of interaction
  e.x0;
  e.y0;
});

// call to remove panzoom handler from the target
unpanzoom()

See test.js for basic use-case.

Alternatives

  • @soulfresh/pan-zoom − compatible fork with elaborate API and fixes.

Credits

This package puts together high-quality tiny components, so acknowledgment to their authors:

License

© 2017 Dmitry Yv. MIT License

Keywords

FAQs

Package last updated on 27 Nov 2020

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