chrvadala / react-svg-pan-zoom

:eyes: A React component that adds pan and zoom features to SVG
https://chrvadala.github.io/react-svg-pan-zoom/
MIT License
681 stars 127 forks source link

Is there a way to set the initial zoom on the svg? #118

Closed oboyle-matthew closed 6 years ago

oboyle-matthew commented 6 years ago

At the moment, I can have a button that, when clicked, will zoom in to a certain area of the svg image. However, I would like it to initially zoom in on this area as soon as the page loads without the user having to select anything. Is there a way of doing this at the moment?

Currently, I am using

<button onClick={e => this.Viewer.setPointOnViewerCenter(100,100,5)}>fitSelection

but I can't call this.Viewer.setPointOnViewerCenter immediately on load because this.Viewer is undefined. I was wondering if there was a way that I could achieve a similar result, possibly by using props of ReactSVGPanZoom?

chrvadala commented 6 years ago

Yes of course. Here there's an example https://jsfiddle.net/1rzxv0pd/

oboyle-matthew commented 6 years ago

Works perfectly, thanks so much!

chrvadala commented 6 years ago

You're welcome