Skip to content

Instantly share code, notes, and snippets.

View aramando's full-sized avatar
🏠
Working from home

Ben C aramando

🏠
Working from home
View GitHub Profile
@aramando
aramando / pinch-zoom.js
Last active March 11, 2021 07:40
Not-so-simple pinch-zoom and drag with Hammer.js.
/**
Enables manual manipulation of an element using
Hammer.js multi-touch events to pinch and drag.
This script is little more sophisticated than others I was able to find
in that it scales around the centre point of the pinch, and constrains
the position of the element in both types of operation to keep as much
of it inside the container as possible.
Prerequisites: Hammer.js, jQuery or jQLite.