draggableUnzoomed behaviour
Closed this issue · 0 comments
This is not an issue, but maybe somebody likes it.
Probably just due to my necessity but..
I've added an option unzoomedFactor: 0.01
I've modified isCloseTo function like this:
isCloseTo = function isCloseTo(value, expected, factor) {
factor = (factor!==undefined) ? factor : 0.01;
return value > expected - factor && value < expected + factor;
};
Than modified its calls like this isCloseTo(this.zoomFactor, 1, this.options.unzoomedFactor)
And added a line in handleZoomEnd
if (!this.options.draggableUnzoomed && isCloseTo(this.zoomFactor, 1, this.options.unzoomedFactor)) this.resetOffset();
And in handleZoom I added the condition if (this.canDrag()) before the this.drag like this
if (this.canDrag()) this.drag(touchCenter, this.lastZoomCenter);
All together makes ::
- when zooming out ends the image replace itself in it's original position
- when zooming close to scale 1 factor and dont whant to drag, it doesn't
- factor is an option so makes more control over it