Creates an animation of type [T] that runs infinitely as a part of the given [InfiniteTransition].
InfiniteTransitionAnimateValueSample
@Composable
fun InfiniteTransitionAnimateValueSample() {
// Creates an [InfiniteTransition] instance to run child animations.
val infiniteTransition = rememberInfiniteTransition()
// Infinitely animate a Dp offset from 0.dp to 100.dp
val offsetX by
infiniteTransition.animateValue(
initialValue = 0.dp,
targetValue = 100.dp,
typeConverter = Dp.VectorConverter,
animationSpec =
infiniteRepeatable(
animation =
keyframes {
durationMillis = 500
0.dp at 200 // ms
80.dp at 300 using FastOutLinearInEasing
}
// Use the default RepeatMode.Restart to start from 0.dp after each iteration
),
)
Box(Modifier.offset(x = offsetX)) {
// Content goes here
}
}