ResetZoom() and resetPan() do nothing when in the same function as pan() zoom()
#280 opened on Jan 23, 2018
Description
Bug report
Expected behaviour
Calling resetZoom() & resetPan(), then later in the same function calling pan() and zoom() should undo any previous zooming and panning to allow panning/zooming to dynamically calculated positions.
Actual behaviour
If resetZoom() & resetPan() are called in the same function prior to calling pan() and zoom(), any previous zooming and panning is not reset, and resetZoom() & resetPan() are seemingly not called, resulting in pan() panning to the wrong positions
Steps to reproduce the behaviour
- Call pan() & zoom() on a svg that has been neither panned and zoomed() and confirm it goes to a given point.
- Reset zoom.
- Pan and zoom to and arbitrary point.
- Call resetZoom() & resetPan() in the same function as pan() & zoom() with the same values in pan() & zoom() as in step 1.
- The panning and zooming goes to a different point than step 1.
Configuration
- svg-pan-zoom version:
3.5.3 - Browser(s):
Chrome - Operating system(s):
Windows 8 - Example code:
this.svgPan.resetZoom(); this.svgPan.resetPan(); this.svgPan.pan({ x: - ((left + right) / 2 - ((this.locationMap.nativeElement.getBoundingClientRect().left + this.locationMap.nativeElement.getBoundingClientRect().right) / 2)), y: - ((top + bottom) / 2 - ((this.locationMap.nativeElement.getBoundingClientRect().top + this.locationMap.nativeElement.getBoundingClientRect().bottom) / 2)) }); this.svgPan.zoom(2);