ste
10/11/2024, 7:50 PMAnimateDecay
? E.g. accelerate until a target velocity is reached. I guess it shouldn't be that hard to implement 😅 Am I missing something?Doris Liu
10/11/2024, 10:09 PMste
10/12/2024, 9:26 PMval rotationAnimatable = remember {
Animatable(0f)
}
LaunchedEffect(rotationAnimatable) {
snapshotFlow { playerState.shouldBePlaying }
.collectLatest { shouldBePlaying ->
if (shouldBePlaying) {
// Sudden resume
rotationAnimatable.animateTo(
rotationAnimatable.value + 360f,
infiniteRepeatable(tween(1818, easing = LinearEasing), repeatMode = RepeatMode.Restart),
)
} else {
// Smooth pause
rotationAnimatable.animateDecay(200f, exponentialDecay())
}
}
}
The animation looks good when pausing - but I can't find a way to make it look the same when resuming 😅Khanzada Kashif
10/13/2024, 5:20 PMinitialVelocity
in animateTo
Doris Liu
10/14/2024, 5:35 PManimationSpec
could work. Then when resuming, you'd need to do in sequence:
rotationAnimatable.animateTo(someTargetForAccelerating, yourCustomSpec)
rotationAnimatable.animateTo( rotationAnimatable.value + 360f,
infiniteRepeatable(tween(1818, easing = LinearEasing), repeatMode = RepeatMode.Restart))