Skip to content

Instantly share code, notes, and snippets.

@adamp
adamp / AnimationClocks.kt
Last active November 8, 2022 15:36
Working with animation frame time in Jetpack Compose
/**
* Returns a [State] holding a local animation time in milliseconds.
* The value always starts at `0L` and stops updating when
* the call leaves the composition.
*/
@Composable
fun animationTimeMillis(): State<Long> {
val millisState = state { 0L }
val lifecycleOwner = LifecycleOwnerAmbient.current
launchInComposition {