Matti MK
12/20/2021, 12:25 PMrememberInfiniteTransition()
as shown below which works nicely, but is not state based.
I’m wondering which animation I should go with to have a repeatable
animation with RepeatMode.Reverse
and have it be state-based? I looked into repeatable
(https://developer.android.com/jetpack/compose/animation#repeatable), but I still have to provide an iteration count, which I do not know beforehand. Thanks 👍
rememberInfiniteTransition().animateValue(
initialValue = 60,
targetValue = 80,
typeConverter = Int.Companion.VectorConverter,
animationSpec = infiniteRepeatable(
animation = tween(durationMillis = ANIMATION_TIME, easing = LinearEasing),
repeatMode = RepeatMode.Reverse
)
)
Doris Liu
12/20/2021, 7:48 PMAnimatable
for switching between infinite animation and state based animations:
val animation = remember { Animatable(60, Int.VectorConverter) }
LaunchedEffects(myState) {
if (myState == isLoading) {
animation.animateTo(80, infiniteRepeatable(...))
} else {
animation.animateTo(stateBasedValue, ...)
}
}