DeferredTargetAnimation
@ExperimentalAnimatableApi
public class DeferredTargetAnimation<T, V : AnimationVector>(
private val vectorConverter: TwoWayConverter<T, V>
)
DeferredTargetAnimation
is intended for animations where the target is unknown at the time of
instantiation. Such use cases include, but are not limited to, size or position animations
created during composition or the initialization of a Modifier.Node, yet the target size or
position stays unknown until the later measure and placement phase.
DeferredTargetAnimation
offers a declarative updateTarget
function, which requires a target
to either set up the animation or update the animation, and to read the current value of the
animation.
Functions
public fun updateTarget(
target: T,
coroutineScope: CoroutineScope,
animationSpec: FiniteAnimationSpec<T> = spring(),
): T
updateTarget
sets up an animation, or updates an already running animation, based on the
target
in the given coroutineScope
. pendingTarget
will be updated to track the last
seen target
.
updateTarget
will return the current value of the animation after launching the animation
in the given coroutineScope
.
Returns
current value of the animation |