Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDoubleClick zoom in zoom out #331

Open
Salitehkat opened this issue Jul 11, 2024 · 2 comments
Open

onDoubleClick zoom in zoom out #331

Salitehkat opened this issue Jul 11, 2024 · 2 comments

Comments

@Salitehkat
Copy link

Please, anyone knows how to zoom in (to the max) and then zoom out (to the min) using onDoubleClick?
Thank you very much

@jeanfrancoisgb
Copy link

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.

@HumboldtK
Copy link

HumboldtK commented Sep 4, 2024

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,
531c2c870d11145d8eec499348f6a6ff

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 -

bd8d47a4199e874b0bfb63944df7c6b3.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants