anvaka / panzoom

Universal pan and zoom library (DOM, SVG, Custom)
https://anvaka.github.io/panzoom/demo/attach-via-script.html
MIT License
1.79k stars 287 forks source link

Zoom with bounds #284

Open bram-aerts opened 2 years ago

bram-aerts commented 2 years ago

The problem occurs when zooming in on an svg image, specifically in the lower-right region, and only when options.bounds = true.

The view region jumps to the far-right-bottom of the image (showing a blank screen).

The issue seems to be resolved when the following code

else {
      var transformAdjusted = keepTransformInsideBounds();
      if (!transformAdjusted) transform.scale *= ratio;
}

is changed to

else {
      var transformAdjusted = keepTransformInsideBounds();
      if (!transformAdjusted || ratio > 1) transform.scale *= ratio;
}

i.e., do not prevent zooming in while guarding bounds.

zanvidmar commented 9 months ago

bram-aerts, thank you for suggestion and just additional remark: This is not only related to svg and lower-right region - I am exiriencing the same issue in general and provided chagne does fix it perectly.