How do I specify “no-animation” `transitionSpec` i...
# compose
a
How do I specify “no-animation”
transitionSpec
in
AnimatedContent
. Before you ask why I would need that, the animation I’m doing is conditional - in one case I want slideInFromRight with slideOutToLeft, in another case I want slideInFromLeft with slideOutToRight, and in a third case I just want the content to be replaced with no animation. The transitionSpec is defined by a separate function, so in the third case I want it to return “no-animation”. Is there a built-in function for that, or do I need to do something silly like a fadeIn/Out with 0 duration tween?
a
EnterTransition.None with ExitTransition.None
👍 3
d
Seems like it would be useful to mention that in the docs here as an option: https://developer.android.com/reference/kotlin/androidx/compose/animation/EnterTransition Please feel free to file a bug on updating the docs. 🙂
z
Whenever the target state changes, you might see additional recompositions even if you specify no animation (as mentioned above). Just something to keep in mind, I had a lot of trouble with debugging this so I thought I'd mention it! Best solution I've found is simply wrapping the relevant parts of the state in another class, this solves the no animation portion of it as well.