saket / telephoto

Building blocks for designing media experiences in Compose UI
https://saket.github.io/telephoto/
Apache License 2.0
872 stars 29 forks source link

Support separate zoom level for double tap and pinch #32

Closed AntsyLich closed 1 day ago

AntsyLich commented 1 year ago

So when user double taps they'll get a 3x zoom but will be able to zoom upto 5x by pinching

saket commented 1 year ago

Agreed, the current spec is not the best for super large images. I need to think of a good API for letting consumers adjust this. Do you have any ideas?

AntsyLich commented 1 year ago

Without giving much thought my idea is that you add the zoom levels to zoom spec and maybe keep the current setup as a extra constructor for people who don't need them to be sperate

saket commented 1 day ago

The next release will introduce an API for overriding the default double click behavior:

https://github.com/saket/telephoto/blob/f0201b80d627ba1950ee460db14c132b3406e553/zoomable/src/commonMain/kotlin/me/saket/telephoto/zoomable/Zoomable.kt#L52

AntsyLich commented 1 day ago

Can we have maxDoubleTapZoomFactor in ZoomSpec? The current implementation works but having both values in ZoomSpec in my opinion will result in less repetitive code across the eco-system.

saket commented 1 day ago

You're right that having a maxDoubleTapZoomFactor parameter will be easier, but it will also prevent developers from building other, more complex kinds of double-tap interactions, such as cycling through three levels of zoom.

I wanted to add another DoubleClickToZoomListener implementation that takes a maxZoomFactor as an argument, but I couldn't think of a good name lol. Suggestions are welcome!