Created
February 3, 2023 04:17
-
-
Save 1jGabriel/21363a1e31f8f50308e173c1f5a8aa35 to your computer and use it in GitHub Desktop.
Animate alignment as state
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
@Composable | |
private fun animateAlignmentAsState( | |
targetAlignment: Alignment, | |
finishedListener: (Float) -> Unit | |
): State<Alignment> { | |
val biased = targetAlignment as BiasAlignment | |
val horizontal by animateFloatAsState( | |
biased.horizontalBias, | |
finishedListener = finishedListener | |
) | |
val vertical by animateFloatAsState(biased.verticalBias, finishedListener = finishedListener) | |
return derivedStateOf { BiasAlignment(horizontal, vertical) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment