Created
September 29, 2022 12:18
-
-
Save nikhil-mandlik-dev/191e07289ec9ab5f510ac045fb16302d to your computer and use it in GitHub Desktop.
Animating Progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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