Boris Kachscovsky
06/23/2021, 5:23 PMDoris Liu
06/23/2021, 5:52 PMBoris Kachscovsky
06/23/2021, 6:05 PMval rotation = remember { Animatable(initialValue = 0f) }
LaunchedEffect(Unit) {
rotation.animateTo(
targetValue = 359f,
animationSpec = infiniteRepeatable(IndeterminateProgressAnimationSpec)
)
}
But it would be great if it could accept some offset
val rotation = remember { Animatable(initialValue = 0f, offset = System.currentTimeMillis() % 359) }
LaunchedEffect(Unit) {
rotation.animateTo(
targetValue = 359f,
animationSpec = infiniteRepeatable(IndeterminateProgressAnimationSpec)
)
}
If the offsets were synced like this, the animations would sync too!
I can’t give it as the initial value because we still want it to animate from 0 - 359, so an offset would be idealDoris Liu
06/23/2021, 6:09 PMoffset
is for the delay I assume?
Consider sequencing the delay and animation in the LaunchedEffect:
val rotation = remember { Animatable(initialValue = 0f) }
LaunchedEffect(Unit) {
delay(offset)
rotation.animateTo(
targetValue = 359f,
animationSpec = infiniteRepeatable(IndeterminateProgressAnimationSpec)
)
}
Boris Kachscovsky
06/23/2021, 6:16 PMDoris Liu
06/23/2021, 6:28 PMThe second animation should then start at 191 given that they’re using the same underlying composable and the offset would be based on the current time.What triggers the 2nd animation to start? It sounds like the stateless animation API (e.g. TargetBasedAnimation) would be best suited for this case. With TargetBasedAnimation, you can drive it with any arbitrary rule that might apply on playtime.
Boris Kachscovsky
06/23/2021, 6:30 PMWhat triggers the 2nd animation to start?It’s the loading spinner on the following screen, but i’ll take a look at
TargetBasedAnimation
! Thanks for the help 🙏Doris Liu
06/23/2021, 6:35 PM