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

Chris Johnson

06/29/2021, 4:12 PM
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

Andrew Neal

06/29/2021, 5:15 PM
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

Chris Johnson

06/29/2021, 5:39 PM
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

Doris Liu

06/29/2021, 10:22 PM
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
1135 Views