I use the jQuery touchy plugin to detect pinch events to give users the ability to zoom in / out, Here is the gist of my code:
var w = 800,
h = 600;
$ ('img'). on ('touchy-pinch', function (e, $ target, data) {
$ (this) .css ({
width: w * data.scale,
height: h * data.scale
});
});
If the user data object contains the following:
- Scale
- previousScale
- currentPoint
- Startpoint
- startDistance
It works great on the first pinch, but as soon as my fingers leave the screen, and then I try to do it again, the image scales again. How can I change my handler so that the image continues where it was stopped, rather than being rescaled? Using previousScale data did not help, as the previous scale just gets reset.
paul smith
source share