Description
Describe the bug
We are using Panzoom to be able to zoom in and out in a large "design board" (20000 x 20000 px) that has inside many other div elements. Sometimes when using zoomWithWheel and while keeping the cursor steady, the board pans to a different direction than just zooming to the certain point.
After investigating a bit, I found out that transforming a board this large and with so many elements can take time, so when using zoomToPoint from zoomWithWheel and getting the dimensions using getDimensions it gets the dimensions of the panzoom element before transforming it. So when adjusting the clientX/clientY for HTML elements, the actual dims.elem.width
and dims.elem.height
are not the expected.
Lines 391 to 397 in 7428761
Your environment
- Version of panzoom: 4.5.1
- Browser and browser version: Tested on Windows: Chrome & Firefox, macOS: Chrome (mouse & trackpad)
Expected behavior
When zooming in a large panzoom elements with many contents, it should zoom correctly to the certain point
Actual behavior
The panzoom element zooms to a wrong location
Steps to reproduce
To reproduce it instead of having a very large panzoom element that can have different results, we can simulate fast wheel events.
I've created an example here.
In this test, there is a small red point element that if you zoom in on it, it should stay inside another blue element.
First reset the board and then you can click the Wheel Event Buttons to test it.