Does `AnimatedVisibility` have a finished listener...
# compose
c
Does
AnimatedVisibility
have a finished listener? I know it has
MutableTransitionState
where you can check if all the animations are done via
isIdle
but I guess I'm looking for an example of when to use that check. I assume it wouldn't be inside the
AnimatedVisibility
content composable and outside of it would make it get hit on every recomposition if I'm remembering the
MutableTransitionState
a
Does 
AnimatedVisibility
 have a finished listener?
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1619066721359200?thread_ts=1619032588.327500&cid=CJLTWPH7S
I know it has 
MutableTransitionState
 where you can check if all the animations are done via 
isIdle
I guess I'm looking for an example of when to use that check
https://cs.android.com/androidx/platform/tools/dokka-devsite-plugin/+/master:testData/compose/samples/animation/samples/AnimatedVisibilitySamples.kt A few sample show it being used with
AnimatedVisibility
.
💯 1
c
This is incredibly helpful, thank you! I'll try out the
DisposableEffect
and the next link actually will help me solve an issue I was having with LazyColumn 😄
🙂 1
d
DisposableEffect
and
MutableTransitionState
are both good ways to get the signal for when the animation has finished. The latter also gives you the info on when the enter animation has finished. One way to use
MutableTransitionState
is to set up a
snapshotFlow
, so you can observe when the initial/target state has changed. Here's an example: https://cs.android.com/androidx/platform/tools/dokka-devsite-plugin/+/master:testDat[…]/samples/animation/samples/AnimatedVisibilitySamples.kt;l=613
1474 Views