Daniele Segato
06/30/2021, 1:41 PMvar nudgeScale by remember {
mutableStateOf(1f)
}
val scale by animateFloatAsState(
targetValue = when {
badgeText.isNullOrBlank() -> 0f
else -> nudgeScale
},
animationSpec = spring(
dampingRatio = Spring.DampingRatioMediumBouncy
)
)
LaunchedEffect(badgeText) {
if (!badgeText.isNullOrBlank()) {
try {
nudgeScale = 1.2f
delay(300)
} finally {
nudgeScale = 1f
}
}
}
I don't like the delay, I would have preferred a way to set a velocity so that it just bounced back to the target value... but I'll take it for now.