Skip to content

brecert/pan-zoom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pan-zoom

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 event is applied to
  e.target;

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

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

See test.js for basic use-case.

Credits

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

License

© 2017 Dmitry Yv. MIT License

About

Pan / zoom for any element

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 83.7%
  • TypeScript 16.3%