Skip to content

Instantly share code, notes, and snippets.

@surajsau
Last active December 7, 2020 19:05
Show Gist options
  • Save surajsau/1260526a3b2d2903ac871850d675dc64 to your computer and use it in GitHub Desktop.
Save surajsau/1260526a3b2d2903ac871850d675dc64 to your computer and use it in GitHub Desktop.
@Composable
fun Slot(
from: Int,
to: Int,
modifier: Modifier = Modifier,
) {
SlotText(
state = transition(
definition = transitionDefinition {
// [1]
state(0) { this[currentSlotValue] = from.toFloat() }
state(1) { this[currentSlotValue] = to.toFloat() }
transition(0 to 1) {
// [2]
currentSlotValue using tween(
durationMillis = abs(to - from) * 3_00,
easing = LinearEasing
)
}
},
initState = 0,
toState = 1,
),
modifier = modifier
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment