Skip to content

Instantly share code, notes, and snippets.

@PiotrPrus
Created December 15, 2021 21:28
Show Gist options
  • Save PiotrPrus/fd79fe0b7be2a411b3c1fedfd77eb426 to your computer and use it in GitHub Desktop.
Save PiotrPrus/fd79fe0b7be2a411b3c1fedfd77eb426 to your computer and use it in GitHub Desktop.
val animatable = remember { Animatable(0f) }
...
//Modifier.tapOrPress
onCompleted = {
scope.launch {
selectedPosition = it
animatable.snapTo(1f)
}
}
...
// @Composable Canvas
drawRoundRect(
brush = brush,
topLeft = Offset(
x = horizontalPadding + distance.times(selectedBar!!.index) - selectionWidth.div(2),
y = chartAreaHeight - chartAreaHeight.times(animatable.value)), // use of animatable value
size = Size(selectionWidth, chartAreaHeight),
cornerRadius = CornerRadius(cornerRadius)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment