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

Downscaling seems to not work properly with limitToBounds #70

Closed
dariuszwisniewski opened this issue Jan 10, 2020 · 2 comments
Closed

Comments

@dariuszwisniewski
Copy link

In case of the scale below 1 with no bounds limit content seems to be positioned randomly while using zoomIn and zoomOut functions.

Configuration:
const options = { minScale: 0.1, maxScale: 3, limitToBounds: false, };

Everything seems to be fine while limitToBounds is set to true.

Video:
https://www.youtube.com/watch?v=h2qhwRi5KbU

@prc5
Copy link
Collaborator

prc5 commented Jan 10, 2020

Thanks for reporting, and for the video! I will take a look over the weekend 👍

@dariuszwisniewski
Copy link
Author

dariuszwisniewski commented Jan 13, 2020

I think it's about mouseX and mousY calculation in the handleZoomControls function. In case of the "negative" scale (scale < 1) you should probably multiply instead of divide. The other way would be to calculate ratio and then do the multiplication.

The base idea:

    var mouseX = (Math.abs(positionX) + wrapperWidth / 2);
    var mouseY = (Math.abs(positionY) + wrapperHeight / 2);
    if (scale < 1) {
        mouseX = mouseX * scale;
        mouseY = mouseY * scale;
    } else {
        mouseX = mouseX / scale;
        mouseY = mouseY / scale;
    }

@prc5 prc5 closed this as completed in f914056 Jan 19, 2020
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

2 participants