usuiat / Zoomable

Jetpack Compose library that enables contents zooming with pinch gesture.
https://usuiat.github.io/Zoomable/
Apache License 2.0
342 stars 16 forks source link

How to prevent over-panning? #158

Closed XamDR closed 6 months ago

XamDR commented 6 months ago

Hello.

First and foremost, thank you for your library. It has helped me to implement a gallery viewer with zoom and pan. However, I found for my use case there is only one small issue. Whenever the image is zoomed, I have this effect:

https://github.com/usuiat/Zoomable/assets/35734934/a6abf85d-0e8c-4048-a06d-04178f43b2bb

I believe this is called over-panning, though I'm not sure. Instead, I'm trying to get something were there is this kind of edge detection:

https://github.com/usuiat/Zoomable/assets/35734934/0716c4d4-c0c1-4216-988b-3bd22ef8977c

That was achieved using the well known TouchImageView library. However, I would like to prefer a pure Jetpack Compose solution.

Thanks in advance.

usuiat commented 6 months ago

@XamDR Did you specify contentSize?

If you use static image resource, you can set contentSize when initializing the ZoomState See SyncImageSample

If you use async loading image like coil, you can use ZoomState.setContentSize() See AsyncImageSample

Thanks.

XamDR commented 6 months ago

Ok, I replicated your example with coil and ZoomState.setContentSize() and I worked great. Thanks!