bumbu/svg-pan-zoom

touch-based pinch-zoom using Hammer.js does not keep image centered during zoom when parent container is offset to the right of the screen

Open

#350 opened on Sep 17, 2019

View on GitHub
 (4 comments) (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

I place two div's side-by-side and apply the recommended event handler usage with Hammer.js:

https://github.com/ariutta/svg-pan-zoom/blob/master/demo/mobile.html

I put together a small demo here:

http://jsfiddle.net/ngkq6L2m/9/

The leftmost container pinch-zooms as expected. However, the rightmost container does not keep the coordinate under the pinch centered while the zoom is occurring. Instead the whole SVG slides left during zoom-in and right during zoom-out. It seems as though some part of the library (not sure if it is svg-pan-zoom or Hammer.js) is assuming that the leftmost pixel offset of the parent container is 0, and when it is positive the appropriate translation is calculated incorrectly.

Contributor guide