Luis Daivid
04/20/2021, 1:09 AMDoris Liu
04/20/2021, 1:38 AMinitialDelay
parameter (a delay that doesn't repeat) on repeatable/infiniteRepeatable
could be useful. Could you file a feature request for this?
For the time being you could achieve this effect by using a coroutine-based animation API (e.g. Animatable, animate, etc) for each animation, and offset the initial start via a suspend delay
before calling animateTo
for starting them.Luis Daivid
04/20/2021, 1:45 AMLuis Daivid
04/20/2021, 1:46 AM@Composable
private fun Circle(color: Color, delayMillis: Int) {
val infiniteTransition = rememberInfiniteTransition()
val animatedFloat by infiniteTransition.animateFloat(
initialValue = 0f, targetValue = -10f, animationSpec = infiniteRepeatable(
animation = tween(400, delayMillis = delayMillis, easing = LinearEasing),
repeatMode = RepeatMode.Reverse
)
)
Box(
modifier = Modifier
.offset(y = animatedFloat.dp)
.padding(horizontal = 2.dp)
.clip(CircleShape)
.size(10.dp)
.background(color)
)
}
Doris Liu
04/20/2021, 1:48 AMinitialDelay
was an idea that I thought could be useful. It isn't implemented yet. You could file an issue here to track the future development of it. 🙂Doris Liu
04/20/2021, 1:54 AM@Composable
private fun Circle(color: Color, delayMillis: Int) {
val animatedFloat = remember { Animatable(0f) }
LaunchedEffect(animatedFloat) {
delay(delayMillis) // delay here to avoid repeated delays
animatedFloat.animateTo(targetValue = -10f, animationSpec = infiniteRepeatable(
animation = tween(400, easing = LinearEasing),
repeatMode = RepeatMode.Reverse
)
)
Box(
modifier = Modifier
.offset(y = animatedFloat.value.dp)
.padding(horizontal = 2.dp)
.clip(CircleShape)
.size(10.dp)
.background(color)
)
}
Luis Daivid
04/20/2021, 2:19 AMHalil Ozercan
07/23/2021, 11:45 AMrememberInfiniteTransition
. LaunchedEffect + delay is useful for Animatable
s but the same hack ofc doesn't work for transition
s.Doris Liu
07/23/2021, 4:25 PMtransition
s, or is this specific to infinite transitions?Halil Ozercan
07/23/2021, 4:37 PMDoris Liu
07/23/2021, 5:18 PMDoris Liu
08/06/2021, 9:31 PMDoris Liu
08/06/2021, 9:32 PMHalil Ozercan
08/07/2021, 6:41 PM