Google is committed to advancing racial equity for Black communities. See how.

VectorizedKeyframesSpec

class VectorizedKeyframesSpec<V : AnimationVector> : VectorizedDurationBasedAnimationSpec<V>
kotlin.Any
   ↳ androidx.compose.animation.core.VectorizedKeyframesSpec

VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be provided via keyframes parameter. VectorizedKeyframesSpec allows very specific animation definitions with a precision to millisecond.

Here's an example of creating a VectorizedKeyframesSpec animation: (keyframes and KeyframesSpec.KeyframesSpecConfig could make defining key frames much more readable.)

    val delay = 120
    val startValue = AnimationVector3D(100f, 200f, 300f)
    val endValue = AnimationVector3D(200f, 100f, 0f)
    val keyframes = VectorizedKeyframesSpec<AnimationVector3D>(
         keyframes = mutableMapOf (
              0 to (startValue to LinearEasing),
              100 to (startValue to FastOutLinearInEasing)
         ),
         durationMillis = 200,
         delayMillis = delay
    )

Summary

Public constructors
<init>(keyframes: Map<Int, Pair<V, Easing>>, durationMillis: Int, delayMillis: Int = 0)

VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.

Public methods
V
getValue(playTime: Long, start: V, end: V, startVelocity: V)

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

V
getVelocity(playTime: Long, start: V, end: V, startVelocity: V)

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

Inherited functions
Properties
Int

the amount of the time the animation should wait before it starts.

Int

total duration of the animation

Public constructors

<init>

VectorizedKeyframesSpec(
    keyframes: Map<Int, Pair<V, Easing>>,
    durationMillis: Int,
    delayMillis: Int = 0)

VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be provided via keyframes parameter. VectorizedKeyframesSpec allows very specific animation definitions with a precision to millisecond.

Here's an example of creating a VectorizedKeyframesSpec animation: (keyframes and KeyframesSpec.KeyframesSpecConfig could make defining key frames much more readable.)

    val delay = 120
    val startValue = AnimationVector3D(100f, 200f, 300f)
    val endValue = AnimationVector3D(200f, 100f, 0f)
    val keyframes = VectorizedKeyframesSpec<AnimationVector3D>(
         keyframes = mutableMapOf (
              0 to (startValue to LinearEasing),
              100 to (startValue to FastOutLinearInEasing)
         ),
         durationMillis = 200,
         delayMillis = delay
    )
Parameters
keyframes: Map<Int, Pair<V, Easing>> a map from time to a value/easing function pair. The value in each entry defines the animation value at that time, and the easing curve is used in the interval starting from that time.
durationMillis: Int total duration of the animation
delayMillis: Int = 0 the amount of the time the animation should wait before it starts. Defaults to 0.

See Also

Public methods

getValue

fun getValue(
    playTime: Long,
    start: V,
    end: V,
    startVelocity: V
): V

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

Parameters
playTime: Long time since the start of the animation
start: V start value of the animation
end: V end value of the animation
startVelocity: V start velocity of the animation

getVelocity

fun getVelocity(
    playTime: Long,
    start: V,
    end: V,
    startVelocity: V
): V

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

Parameters
playTime: Long time since the start of the animation
start: V start value of the animation
end: V end value of the animation
startVelocity: V start velocity of the animation

Properties

delayMillis

val delayMillis: Int

the amount of the time the animation should wait before it starts. Defaults to 0.

durationMillis

val durationMillis: Int

total duration of the animation