retarget

fun retarget(target: T, spec: AnimationSpec<T>)

Starts an animation toward target using the given spec.

If an animation is already running, it is interrupted: the current velocity is captured and passed to the new animation for smooth retargeting (particularly effective with spring animations).

Must be called on the main thread.

Parameters

target

The target value to animate toward.

spec

The animation specification (e.g., tween(), spring()).