I'm not sure if there is a better way, but I manag...
# compose
d
I'm not sure if there is a better way, but I managed to obtain something like this:
Copy code
var 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.