lilypuchi
12/09/2020, 5:15 PMbounce
isn’t changing when I trigger bounce.animateTo(..)
in onClick
Would really appreciate some help here 🙇
@Composable
fun Bouncy(modifier: Modifier = Modifier) {
val bounce = animatedFloat(initVal = 0f)
Box(modifier = modifier
.size(width = 150.dp, height = 50.dp)
.clip(shape = GenericShape {
val height = it.height * bounce.value
relativeMoveTo(0f, 0f)
relativeLineTo(it.width / 2, height)
relativeLineTo(it.width / 2, -height)
})
.background(color = Color.Red)
.clickable(onClick = {
bounce.animateTo(
targetValue = 1f,
anim = spring(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessLow
),
)
})
)
}
Jeisson Sáchica
12/09/2020, 6:08 PMDoris Liu
12/10/2020, 12:24 AM.clickable(..)
to immediately after .size(...)
to ensure it has a reasonable touch area.lilypuchi
12/10/2020, 2:15 AM