useAnimationGroup
fun <S> ComponentScope.useAnimationGroup(targetState: S, trigger: AnimationTrigger = AnimationTrigger.Immediate, label: String = "transition"): AnimationGroup<S>
Coordinates multiple animated properties that respond to a shared targetState.
This is the Litho equivalent of Compose's updateTransition. The returned AnimationGroup provides animateFloat, animateInt, animateColor, and animateDimen methods for adding animations that all retarget together when targetState changes.
val transition = useAnimationGroup(expanded)
val height = transition.animateDimen(
transitionSpec = {
when {
false.isTransitioningTo(true) -> spring(stiffness = Stiffness.Low)
else -> tween(200.ms)
}
},
) { state -> if (state) 200.dp else 56.dp }
val alpha = transition.animateFloat { state -> if (state) 1f else 0f }Content copied to clipboard
Return
An AnimationGroup for adding animations.
Parameters
targetState
The state to animate toward. Changes trigger retargeting of all animations.
trigger
Controls when the animation begins receiving frame callbacks. Defaults to AnimationTrigger.Immediate.
label
Optional label for debugging/tracing.