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

Notify on scale changes #148

Closed pkrystyniak-jt closed 6 months ago

pkrystyniak-jt commented 7 months ago

Hey, I have an UI element over the zoomable Image, that I want to hide or show depending if the image is zoomed in or out. I don't see a direct way to observe the scale changes at this moment. Would it be possible to f.e. add a callback for scale changes?

usuiat commented 7 months ago

Hi, @pkrystyniak-jt Could you explain in a little more detail? Is it not enough to observe ZoomState.scale?

pkrystyniak-jt commented 7 months ago

You're right, I missed the fact it's a mutable state. I might observe it by using snapshotFlow. That should do, thanks for leading me to this solution.

LaunchedEffect(zoomState) {
    snapshotFlow { zoomState.scale }.collect { scale ->
        ...
    }
}