Open Salitehkat opened 4 months ago
I'm looking for the same thing and even by trying to disabling the double click completely and manage it myself, it does not work.
I was able to modify the default double click behavior so it zooms in to the max on double click and then zooms all the way back out on double click. I added var isZoomedIn = false;
in the main panzoom.js file on line 119,
Then with the function onDoubleClick on line 765 we can do
function onDoubleClick(e) {
beforeDoubleClick(e);
var offset = getOffsetXY(e);
if (transformOrigin) {
offset = getTransformOriginOffset();
}
var defaultZoom = 0.7; // Replace with your default zoom level
var maxZoom = 100; // Replace with your maximum zoom level
var currentScale = transform.scale;
if (!isZoomedIn) {
smoothZoom(offset.x, offset.y, maxZoom / currentScale);
isZoomedIn = true;
} else {
smoothZoom(offset.x, offset.y, defaultZoom / currentScale);
isZoomedIn = false;
}
}
The result is -
https://github.com/user-attachments/assets/f9f0367c-5a4e-4c66-b15c-0eeefc6fcb63
Please, anyone knows how to zoom in (to the max) and then zoom out (to the min) using onDoubleClick? Thank you very much