Skip to content

Instantly share code, notes, and snippets.

@surajsau
Last active December 7, 2020 19:08
Show Gist options
  • Save surajsau/36fae9cdfef6ab342bfb07e74af9a3a1 to your computer and use it in GitHub Desktop.
Save surajsau/36fae9cdfef6ab342bfb07e74af9a3a1 to your computer and use it in GitHub Desktop.
val currentSlotValue = FloatPropKey()
@Composable
fun SlotText(
state: TransitionState,
modifier: Modifier = Modifier
) {
// [1]
var current = state[currentSlotValue].toInt()
// [2]
val delta = state[currentSlotValue] - state[currentSlotValue].toInt()
// [3]
val yOffset = (delta * 50).dp
Box(modifier = ..clipToBounds()) {
// [4]
Text(
text = "$current",
..
modifier = Modifier.offset(y = 0.dp - yOffset)
)
// [5]
Text(
text = "${(current + 1)%10}",
..
modifier = Modifier.offset(y = 50.dp - yOffset)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment