bumbu/svg-pan-zoom

ResetZoom() and resetPan() do nothing when in the same function as pan() zoom()

Open

#280 opened on Jan 23, 2018

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (383 forks)batch import
bughelp wanted

Repository metrics

Stars
 (1,585 stars)
PR merge metrics
 (No merged PRs in 30d)

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

  1. Call pan() & zoom() on a svg that has been neither panned and zoomed() and confirm it goes to a given point.
  2. Reset zoom.
  3. Pan and zoom to and arbitrary point.
  4. Call resetZoom() & resetPan() in the same function as pan() & zoom() with the same values in pan() & zoom() as in step 1.
  5. 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);

Contributor guide