rob42
05/24/2024, 12:54 PMval offsetY by rememberInfiniteTransition().animateFloat(
initialValue = -3f,
targetValue = 3f,
animationSpec = infiniteRepeatable(
animation = tween(easing = EaseInOutCubic, durationMillis = 2500),
repeatMode = RepeatMode.Reverse))
Box(modifier = Modifier.size(128.dp).padding(32.dp)) {
Box(modifier = Modifier.size(64.dp).offset(y = offsetY.dp).background(Color.Red))
}
Sergey Y.
05/24/2024, 1:35 PMSergey Y.
05/24/2024, 1:44 PMSergey Y.
05/24/2024, 1:44 PMTo ensure your app does as little as possible while animating, choose the lambda version of awhere possible. This skips recomposition and performs the animation outside of the composition phase, otherwise useModifier
, as this modifier always runs in the draw phase. For more information on this, see the deferring reads section in the performance documentation.Modifier.graphicsLayer{ }
romainguy
05/24/2024, 2:15 PMrob42
05/24/2024, 3:25 PMrob42
05/24/2024, 3:26 PM