0

To change the position of an SVG with SvgPanZoom one has to use

panZoomInstance.pan({x: *value*, y: *value*});

But this causes SvgPanZoom to move the SVG initially from center to the new position, as it will first place the SVG in the middle of the viewport by default.

Is there a way to force a different center point of the SVG onload before SvgPanZoom will place the SVG?

Best, hirschferkel

Hirschferkel
  • 291
  • 4
  • 20

1 Answers1

0

svg-pan-zoom has 3 options that you can disable:

, fit: true
, contain: false
, center: true
bumbu
  • 1,297
  • 11
  • 29
  • Yes I know, but this will cause a jumping SVG onload with .pan option, as I wrote... Is it possible to insert some Javascriptcode somewhere in svgpanzoom.js to edit the center point so svgpanzoom will initially load a different center for the svg? even with `, fit: false, contain: false, center: false` >> svgpanzoom will center the svg onload. – Hirschferkel May 31 '18 at 10:24
  • 2
    O.k. it's just because the SVG gets loaded first and than svg-pan-zoom gets initalized. So the solution ist to hide the svg as long as svg-pan-zoom is initialized and than show the svg after it has been panned by svg-pan-zoom (within the onload function) – Hirschferkel Jun 01 '18 at 09:55