Skip to content

A Javascript library that makes it easy to detect pinch and spread motions and zoom based on them

License

Notifications You must be signed in to change notification settings

timjrobinson/pinch-to-zoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pinch to Zoom

A Javascript library that makes it easy to detect pinch and spread motions. This can be used for more than zooming, but that's what it was originally made for.

This is inspired by https://github.com/anvaka/wheel which makes it super easy to detect wheel scrolling, I wanted something similar for pinching / spreading.

This library uses QuoJS for the cross platform touch handling. If you already have QuoJS on your site you can remove the lines including it at the top of pinch-to-zoom.js.

Usage

addPinchListener(domElement, function (event) {
    // All event properties are described below
    zoom(event.x, event.y, event.delta);
});

function zoom(x, y, delta) {

}

See the example for how to use this with Pixi.js

Event properties

  • x / y - The x and y coordinates the user appears to be pinching towards. This is in pixels from the top left of the screen.
  • delta - The total movement the user has performed with the pinch in pixels.

License

MIT

About

A Javascript library that makes it easy to detect pinch and spread motions and zoom based on them

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published