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

Dejan Dobnikar

04/05/2022, 12:23 PM
Hi, is there a way to pause/resume Compose animations? Something similar to
Animator.pause()
/`Animator.resume()` , which would work with all animation types (animate*asState/Animatable/updateTransition)? In the API reference I haven’t found anything related. For example I would like to pause/resume long-running animation on button click and also pause animation if activity is paused. One idea that I had is to have custom
AnimationSpec
and override
vectorize
fun which would return
VectorizedAnimationSpec
which would handle pause, but that does not sound like the best way to do it.
m

MR3Y

04/05/2022, 1:16 PM
Not all animation types support pausing/resuming. the core idea behind things like animate*AsState is to be a "fire & forget" animation
94 Views