Ahmed Sellami
09/08/2021, 9:11 PMval funnelTranslation by animateFloatAsState(
targetValue = if (isDeleted.value)
-radius * 3f - particleRadius
else
(offsetX.value - radius * 3f - particleRadius).coerceAtMost(0f)
)
isDeleted is a boolean state, and offsetX is an Animateable.
Usage:
Box {
Canvas(
Modifier.height(imageSizeDp)
)
{
translate(funnelTranslation) {
drawPath(
path = drawSideShape(radius = radius, particleRadius = particleRadius * 3 / 4f),
color = shoesArticle.color
)
}
}
}
adjpd
09/08/2021, 10:25 PMDoris Liu
09/08/2021, 10:42 PMAnimatable
? Looking at the code you currently have, it looks like you are trying to animate to the new offsetX rather than snap to it. If that offsetX is updated by gesture, you'll be spending a few frames animating to where you drag therefore always lagging behind.Ahmed Sellami
09/09/2021, 2:20 AM