Skip to content

Instantly share code, notes, and snippets.

@pauloaapereira
Created March 16, 2021 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauloaapereira/4a883ec7963dcf728371edbf76fd361a to your computer and use it in GitHub Desktop.
Save pauloaapereira/4a883ec7963dcf728371edbf76fd361a to your computer and use it in GitHub Desktop.
Jetpack Compose - Pulsating Effect - 2
@Composable
fun Pulsating(pulseFraction: Float = 1.2f, content: @Composable () -> Unit) {
val infiniteTransition = rememberInfiniteTransition()
val scale by infiniteTransition.animateFloat(
initialValue = 1f,
targetValue = pulseFraction,
animationSpec = infiniteRepeatable(
animation = tween(1000),
repeatMode = RepeatMode.Reverse
)
)
Box(modifier = Modifier.scale(scale)) {
content()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment