hi all!, does anybody know how can I restart a Tra...
# compose
j
hi all!, does anybody know how can I restart a Transition?
Copy code
val currentState = remember {
    MutableTransitionState(TransitionState.START)
        .apply { targetState = TransitionState.END }
}
val transition = updateTransition(currentState, label = "")
the initial composition triggers the transition but I need to restart it whenever a Canvas draws something, which happens some time after the initial Transition is triggered. I've tried doing
currentState.targetState = TransitionState.END
right before drawing inside the Canvas but it doesn't work.
d
You could either 1) pass a new MutableTransitionState instance to updateTransition, which will restart the transition, or 2) add a
key
around
updateTransition
and change the key param to restart
🙌 1
j
I went for the first one but the
key
also sounds like a suitable solution. Thanks!
👍 1