Hello, I have tried to rebuild my custom progress ...
# compose
n
Hello, I have tried to rebuild my custom progress bar in compose but faced issue, delay in TweenSpec works not as expected:
Copy code
val transition = rememberInfiniteTransition()
val value = transition.animateFloat(
        0.5f,
        1f,
        infiniteRepeatable(
            repeatMode = RepeatMode.Reverse,
            animation = tween(
                durationMillis = 650,
                delayMillis = 160,
                easing = BezierEasing
            )
        )
    )
it applies delay on each iterate, is there any legit way to delay only first iterate? like startDelay in ValueAnimator?
d
Given the number of times it came up, I'd say initial delay support will come very soon. 😛 For now you could manually delay the animation with
delay(...)
in a `LaunchedEffect`:
Copy code
LaunchedEffect(Unit) {
   delay(..)
   animate(0.5f, 1f, animationSpec = infiniteRepeatable(..)) {value, _ -> 
   // do something with the value 
   }
}
Tracked here: https://issuetracker.google.com/195079908 Please feel free to star it
n
Thank you for snippet and pointing to issue, problem with Launched effect that I need 3 value to be animated, each of them delayed on certain amount of time
d
You could create one coroutine for each infinite animation in the
CoroutineScope
provided by `LaunchedEffect`:
Copy code
LaunchedEffect(Unit) {
            launch {
                delay(..)
                animate(..)
            }
            launch {
                delay(..)
                animate(..)
            }
            launch {
                ...
            }
        }
n
Yep I did thank you, just looks not so clear as I wanted ))
d
No problem. Glad you prefer the infiniteTransition approach. 🙂 Will add the initial delay support soon.