VectorizedFloatAnimationSpec


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.

Cmn

Public functions

open Long
getDurationNanos(initialValue: V, targetValue: V, initialVelocity: V)

Calculates the duration of an animation.

Cmn
open V
getEndVelocity(initialValue: V, targetValue: V, initialVelocity: V)

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

Cmn
open V
getValueFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    targetValue: V,
    initialVelocity: V
)

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

Cmn
open V
getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    targetValue: V,
    initialVelocity: V
)

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

Cmn

Inherited properties

From androidx.compose.animation.core.VectorizedFiniteAnimationSpec
open Boolean

Whether or not the VectorizedAnimationSpec specifies an infinite animation.

Cmn

Public constructors

VectorizedFloatAnimationSpec

<V : AnimationVector> VectorizedFloatAnimationSpec(
    anim: FloatAnimationSpec
)

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

Parameters
anim: FloatAnimationSpec

the animation spec for animating each dimension of the AnimationVector

Public functions

getDurationNanos

open fun getDurationNanos(initialValue: V, targetValue: V, initialVelocity: V): Long

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
initialValue: V

start value of the animation

targetValue: V

end value of the animation

initialVelocity: V

start velocity of the animation

getEndVelocity

open fun getEndVelocity(initialValue: V, targetValue: V, initialVelocity: V): V

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
initialValue: V

start value of the animation

targetValue: V

end value of the animation

initialVelocity: V

start velocity of the animation

getValueFromNanos

open fun getValueFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    targetValue: V,
    initialVelocity: V
): V

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

Parameters
playTimeNanos: Long

time since the start of the animation

initialValue: V

start value of the animation

targetValue: V

end value of the animation

initialVelocity: V

start velocity of the animation

getVelocityFromNanos

open fun getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    targetValue: V,
    initialVelocity: V
): V

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

Parameters
playTimeNanos: Long

time since the start of the animation

initialValue: V

start value of the animation

targetValue: V

end value of the animation

initialVelocity: V

start velocity of the animation