{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

VectorizedFloatAnimationSpec

public final class VectorizedFloatAnimationSpec<V extends AnimationVector> implements VectorizedFiniteAnimationSpec


A convenient implementation of VectorizedFloatAnimationSpec that turns a FloatAnimationSpec into a multi-dimensional VectorizedFloatAnimationSpec, by using the same FloatAnimationSpec on each dimension of the AnimationVector that is being animated.

Summary

Public constructors

Creates a VectorizedAnimationSpec from a FloatAnimationSpec.

Public methods

long
getDurationNanos(
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the duration of an animation.

@NonNull V
getEndVelocity(
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the end velocity of the animation with the provided start/end values, and start velocity.

@NonNull V
getValueFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

@NonNull V
getVelocityFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Inherited methods

From androidx.compose.animation.core.VectorizedFiniteAnimationSpec
boolean

Whether or not the VectorizedAnimationSpec specifies an infinite animation.

Public constructors

VectorizedFloatAnimationSpec

public <V extends AnimationVector> VectorizedFloatAnimationSpec(
    @NonNull FloatAnimationSpec anim
)

Creates a VectorizedAnimationSpec from a FloatAnimationSpec. The given FloatAnimationSpec will be used to animate every dimension of the AnimationVector.

Parameters
@NonNull FloatAnimationSpec anim

the animation spec for animating each dimension of the AnimationVector

Public methods

getDurationNanos

public long getDurationNanos(
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the initialValue, targetValue values, and initialVelocity.

Parameters
@NonNull V initialValue

start value of the animation

@NonNull V targetValue

end value of the animation

@NonNull V initialVelocity

start velocity of the animation

getEndVelocity

public @NonNullgetEndVelocity(
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the end velocity of the animation with the provided start/end values, and start velocity. For duration-based animations, end velocity will be the velocity of the animation at the duration time. This is also the default assumption. However, for physics-based animations, end velocity is an AnimationVector of 0s.

Parameters
@NonNull V initialValue

start value of the animation

@NonNull V targetValue

end value of the animation

@NonNull V initialVelocity

start velocity of the animation

getValueFromNanos

public @NonNullgetValueFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

Parameters
long playTimeNanos

time since the start of the animation

@NonNull V initialValue

start value of the animation

@NonNull V targetValue

end value of the animation

@NonNull V initialVelocity

start velocity of the animation

getVelocityFromNanos

public @NonNullgetVelocityFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V targetValue,
    @NonNull V initialVelocity
)

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Parameters
long playTimeNanos

time since the start of the animation

@NonNull V initialValue

start value of the animation

@NonNull V targetValue

end value of the animation

@NonNull V initialVelocity

start velocity of the animation