These are chat archives for openseadragon/openseadragon

17th
Aug 2017
John
@jp887
Aug 17 2017 20:12
Hi. I have a use case that I cant figure out and I'm wondering if someone could point me in the right direction please? I'm displaying a very large deep zoom image and I'd like my app to load showing a specific small area within the image rather than the default behavior which is to fit the entire image into the viewport area (the "home" position). I've tried calling the panTo/zoomTo APIs immediately after creating the viewer but that doesn't seem to work (I assume because the images are loaded async so pan/zoom won't work straight away??). Is there a way to set a "start" position/zoom level? Or perhaps a way to register a callback to fire when initialization is complete so I can use panTo/zoomTo? Thanks.
Ian Gilman
@iangilman
Aug 17 2017 20:30
@jp887 Yes, you're correct that it's because of the async nature. You want viewer.addHandler('open', handler)
...and I recommend using viewer.viewport.fitBounds for zooming to the appropriate location; it gives you the most control
Remember that fitBounds uses viewport coordinates (which go from 0 on the left of the image to 1 on the right by default, but which you can change if you want): http://openseadragon.github.io/examples/viewport-coordinates/