animateContentSize

fun SwingModifier.animateContentSize(animationSpec: FiniteAnimationSpec<Dimension> = spring(stiffness = Spring.StiffnessMediumLow, visibilityThreshold = dimensionVisibilityThreshold()), alignment: Alignment = Alignment.TopStart, finishedListener: (initialValue: Dimension, targetValue: Dimension) -> Unit? = null): SwingModifier

Animates this component's size when the measured size of its content changes.

The first measured size is used as is, so nothing animates when the component appears. A change during a running animation retargets it from the current size and speed.

While the size animates, the content is placed inside the animated box by alignment and clipped to it. The clip is a step of the component's decoration, so the component must be Decoratable, as a Row, Column, Box and a custom Layout are.

Return

this modifier with the size animation declared on it.

Parameters

animationSpec

how the size travels, a medium-low stiffness spring by default.

alignment

where the content sits inside the box while it travels.

finishedListener

called when a size animation finishes, with the size it started from and the size it settled at. A retargeted animation does not call it. null by default.

Throws

as the component is first laid out, if it is not decorated.