panzoom icon indicating copy to clipboard operation
panzoom copied to clipboard

Change bounds API

Open anvaka opened this issue 6 years ago • 5 comments

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

anvaka avatar Jun 28 '19 03:06 anvaka

I agree this functionality would be very welcome!

vi-cat avatar Aug 05 '19 13:08 vi-cat

@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!

mreinstein avatar Nov 17 '19 06:11 mreinstein

Bounds: true is not even working here. It doesn't prevent the image I am panzooming from being panned outside of its container

tommedema avatar Dec 22 '19 01:12 tommedema

@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
});

littlee avatar Apr 14 '20 07:04 littlee

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.

TimoKunze avatar Jul 06 '20 11:07 TimoKunze