Question:
I want to bound the pan of the SVG so that when no zoom has been applied, no pan is possible, however as you zoom in you can pan around within the bounds of the SVG.
Visual Example: In the image below the zoomed viewport in the center would be able to pan to the edges of the SVG but no further.
However this is very different from the pan example given and I can't work our how to alter it to behave as such. How would you do this? (also am I missing an easy built in way to do this)?
Problems I've bumped into trying to solve this
- Each of the limits sets the movement in pixels allowed in the correct direction. i.e. bottomLimit = 200 allows you to move up by 200 pxs. So at default zoom I need all the limits set to 0, however I can't work out how to recognise default zoom as realZoom changes depending on the browser window size.
- In the visual example, if we want to set bottomLimit to bound the SVG correctly, it needs to be equal to x, but I can't work out how to calculate x. (topLimit would need to be equal to y, etc.)