transition
Adds a diff-based transition to the host represented by this Style.
Style.transition declares which mounted host properties should animate when their resolved values change across Litho layout states. Litho reads the previous mounted value or any in-flight animated value as the animation start, reads the current layout/mount output as the target, and drives the selected properties with the supplied AnimationSpecs. Callers do not provide explicit from or to values.
This API is intended for visual host changes that should not drive progressive Yoga relayout. In particular, StyleTransitionScope.bounds animates mount-space x, y, width, and height after the new layout has already been calculated. Siblings are laid out at their final positions immediately while the transitioned host visually moves or resizes to that final state. Use state-based animation APIs such as useAnimatedDimen when parent or sibling layout should reflow every frame.
Keyless Style.transition uses Litho's structural identity for the same host across renders. When a component needs semantic identity, such as a list item moving across structure, provide that identity through normal Litho component identity mechanisms like key(...) rather than through the transition itself. Style.transition cannot be combined with legacy Style.transitionKey(...) on the same component.
Multiple Style.transition entries on the same Style compose. If the same property is declared more than once, the later declaration wins.
Example:
Row(
style =
Style.width(if (expanded) 200.dp else 120.dp)
.alpha(if (enabled) 1f else 0.4f)
.transition {
bounds = spring()
alpha = tween(duration = 120.ms)
}
)