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

Filip Wiesner

12/01/2021, 8:18 AM
Is there a way to use only enter (or only exit) animation in
AnimatedVisibility
? I tried
fade
with
tween(duration = 0)
but there is still small delay before the view disappears.
a

Albert Chang

12/01/2021, 8:21 AM
There are
EnterTransition.None
and
ExitTransition.None
.
1
f

Filip Wiesner

12/01/2021, 8:24 AM
I looked through the source code but somehow missed those. Thank you 🙏
👍 1
z

Zoltan Demant

12/01/2021, 8:32 AM
I'd love to know if that works for you @Filip Wiesner! Whenever I use it, the enter/exit transition is just cut off sometimes.
f

Filip Wiesner

12/01/2021, 8:41 AM
Sadly it doesn't. It's the same as with
tween(duration = 0)
. It's just not the same as if it's removed from composition with condition directly and has slight delay
It works like 1/10 times
z

Zoltan Demant

12/01/2021, 8:54 AM
Perhaps worth to file a bug report/feature request?
f

Filip Wiesner

12/01/2021, 8:54 AM
Yeah, I'll do it when I have time
👍🏽 1
c

Chris Sinco [G]

12/01/2021, 9:55 AM
cc @Doris Liu
d

Doris Liu

12/01/2021, 6:49 PM
@Zoltan Demant Could you share more details on the transitions being cut off? The
Enter/ExitTransition.None
is currently handled as an empty transition. In the exit case, it should finish right away (i.e. in a frame). We don't currently short-circuit for
None
, so it does take a frame to finish. Maybe it would make sense to treat it as a special case. @Filip Wiesner Could you share a video of what it looks like when it doesn't work? Curious to see what you are trying to achieve. 🙂
z

Zoltan Demant

12/02/2021, 4:44 AM
@Doris Liu Sure, I think it happens due to the same reasoning you just gave - its handled as an empty transition, and as such any pending transition is cancelled. When navigating between content A -> B, Ill get repeated calls to
transitionSpec
even though there is no targetState change, for those scenarios I simply specified
Enter/Exit.None
but it also results in the A -> B transition being cut off if the
transitionSpec
is called again before the animation finishes, which is often the case when B changes its contents during the transition (e.g. loading, then actual contents). I ended up always creating an animation instead, so even if the transition goes from B -> B, Ill do the same thing as A -> B; it works almost flawlessly, but in rare cases the wrong transition ends up happening.
d

Doris Liu

12/03/2021, 1:53 AM
@Zoltan Demant Could you record a video of the transition being cut off? That'd be helpful for me to visualize it. 🙏 This sounds like a bug, if you could file a bug with a snippet, I'd really appreciate it. 🙂
z

Zoltan Demant

12/03/2021, 6:04 AM
@Doris Liu I just tried recreating it, and I couldnt! If I were to guess,
contentKey
is what solved it. I now use it in both this transition, and the "loading then content" one; and Im no longer seeing additional
transitionSpec
calls!
6 Views