https://kotlinlang.org logo
#compose
Title
# compose
f

Filip Wiesner

03/24/2022, 12:01 PM
Hey, how can I have a pager where each item is also zoomable? Right now I have my
zoomable
modifier which contains a
pointerInput
with
detectTransformGestures
. It works all fine but now I have to use this
modifier
on items inside
HorizontalPager
and because (I presume) the
pointerInput
consumes all the events, I cannot move the pager. What I've tried is to dispatch the unused offset (pan with one finger) as a scroll to the pager but I don't know how to handle the fling after the scroll. Is there some way to handle my own fling? Or is there some more simple way to achieve this that I am missing?
a

Albert Chang

03/24/2022, 2:01 PM
You need to write the gesture detector yourself (and I don’t think fling is relevant). Btw Zoomable has what you want. See the sample.
f

Filip Wiesner

03/24/2022, 2:06 PM
Yeah, I know about your library and was "inspired" by it when creating my own zoomable 😅 I just didn't want to introduce another dependency to our project. I might reevaluate that decision now
I think I'll end up using your library Albert, thank you 👌 Just wondering, is there some way to animate back to scale 1:1 when user has less than two fingers active? It other words, let user zoom only with pinch-to-zoom and reset scale when they lift a finger?
a

Albert Chang

03/24/2022, 4:05 PM
Yes. You can use
OverZoomConfig(1f, 1f)
.
21 Views