Zoltan Demant
10/05/2021, 5:22 AMAnimatedContent
? 🧵👀Albert Chang
10/05/2021, 6:06 AMAnimatedVisibilityScope
, you can use the transition
property to create your own animation. See here for example.Zoltan Demant
10/05/2021, 6:15 AMinitialState
and targetState
, is there a way to use the like in the content block as well or should I encode this in the targetState property? Id basically like to animate in/out a scrim over the previous screen whenever Im navigating to the next screen (and never for back navigation).Doris Liu
10/06/2021, 5:24 PMZoltan Demant
10/07/2021, 3:41 AMDoris Liu
10/07/2021, 8:59 PMinitialState
from the Transition if you use the Transition#AnimatedContent
API. It'd be something like:
val t = updateTransition(..)
t.AnimatedContent(...) {
// In the content block, remember the current/initialState when the content is first added
val initialState = remember { t.currentState }
// Add the scrim animation using AnimatedVisibilityScope#transition
val scrimAlpha by transition.animatedFloat {
if (it != Visible && initialState == foo) {
0f
} else {
if
}
}
}
Zoltan Demant
10/08/2021, 8:29 AMAnimatedContent.content
scope represents the enter or exit content that Im animating to. I think a transition between Visible -> PostExit
represents exit, but Im not seeing the expected results when following it.
I think the logic should be pretty straight-forward. Each state has a size variable, when the old size < new size, the exit content should have a scrim, basically.Doris Liu
12/03/2021, 1:50 AMAnimatedVisbilityScope#transition.targetState
against PostExit
. What is the result you see?Zoltan Demant
12/03/2021, 8:03 AMDisposableEffect.onDispose
is called exactly when the transition is complete.
initialContentExit = fadeOut(
targetAlpha = 0.8f
)
Doris Liu
12/04/2021, 12:36 AMso while the new content is sliding in from the bottom, the old content has a scrim for 90% of the duration, and the last 10% just renders the old content as white (which is my background color) until the new content covers it entirely.
This sounds to me like the old content was removed after 90% of the total duration, which is likely due to the exit animation finishing. Can you try using a
tween
with the same duration for enter & exit and see if you still observe the same behavior?
It's possible that having the old content stick around until both enter & exit transition finish would be more intuitive.Zoltan Demant
12/05/2021, 6:11 AM