Skip to content

Instantly share code, notes, and snippets.

@nikhil-mandlik-dev
Created September 29, 2022 12:18
Show Gist options
  • Save nikhil-mandlik-dev/191e07289ec9ab5f510ac045fb16302d to your computer and use it in GitHub Desktop.
Save nikhil-mandlik-dev/191e07289ec9ab5f510ac045fb16302d to your computer and use it in GitHub Desktop.
Animating Progress
// Defining infiniteTransition to calculate progress value
val infiniteTransition = rememberInfiniteTransition()
val progress by infiniteTransition.animateFloat(
initialValue = 0f,
animationSpec = infiniteRepeatable(
animation = tween(2000),
repeatMode = RepeatMode.Restart
),
targetValue = 1f
)
// calculating position and tangent and storing it in float array
val pos = FloatArray(2)
val tan = FloatArray(2)
PathMeasure().apply {
setPath(infinityPath.asAndroidPath(), false)
getPosTan(length * progress, pos, tan)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment