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.
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
- 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.
MIT