Change bounds API
We need a clean API to let consumers define pan/zoom bounds. Current implementation is not flexible enough.
See https://github.com/anvaka/panzoom/pull/106#issuecomment-504704235
I agree this functionality would be very welcome!
@anvaka I would definitely appreciate a straightforward API for this.
I'm building a game and want to allow people to pan and zoom the map without being able to pan outside the bounds of the game world at whatever zoom level they're at.
How would I do this with the present api? My current prototype:
https://test-zoom-pan-otszdjlutb.now.sh
Thanks for a great library by the way!
Bounds: true is not even working here. It doesn't prevent the image I am panzooming from being panned outside of its container
@tommedema
I think you would like to set boundsPadding: 1
my problem is when using bounds with maxZoom and minZoom, it doesn't work well when zooming
panzoom(element, {
maxZoom: 5,
minZoom: 0.5,
bounds: true,
boundsPadding: 1
});
Currently I set bounds so that the pannable element cannot be moved completely outside the viewport. This works fine as long as I don't zoom in or out. If I zoom out, panning the element is limited more than necessary. If I zoom in I still can move the element completely outside the viewport.