Is there a way to use only enter (or only exit) an...
# compose
f
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
There are
EnterTransition.None
and
ExitTransition.None
.
โž• 1
f
I looked through the source code but somehow missed those. Thank you ๐Ÿ™
๐Ÿ‘ 1
z
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
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
Perhaps worth to file a bug report/feature request?
f
Yeah, I'll do it when I have time
๐Ÿ‘๐Ÿฝ 1
c
cc @Doris Liu
d
@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
@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
@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
@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!