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

KeyframesSpec.KeyframesSpecConfig


KeyframesSpecConfig stores a mutable configuration of the key frames, including durationMillis, delayMillis, and all the key frames. Each key frame defines what the animation value should be at a particular time. Once the key frames are fully configured, the KeyframesSpecConfig can be used to create a KeyframesSpec.

import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.keyframes
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp

// Use FastOutSlowInEasing for the interval from 0 to 50 ms, and LinearOutSlowInEasing for the
// time between 50 and 100ms
keyframes<DpOffset> {
    durationMillis = 200
    DpOffset(0.dp, 0.dp) at 0 with LinearEasing
    DpOffset(500.dp, 100.dp) at 100 with LinearOutSlowInEasing
    DpOffset(400.dp, 50.dp) at 150
}
See also
keyframes

Summary

Public constructors

Cmn

Public functions

infix KeyframesSpec.KeyframeEntity<T>
T.at(timeStamp: Int)

Adds a keyframe so that animation value will be this at time: timeStamp.

Cmn
infix KeyframesSpec.KeyframeEntity<T>
T.atFraction(fraction: Float)

Adds a keyframe so that the animation value will be the value specified at a fraction of the total durationMillis set.

Cmn
open operator Boolean
equals(other: Any?)
Cmn
open Int
Cmn
infix Unit

Adds an Easing for the interval started with the just provided timestamp.

Cmn

Public properties

Int

The amount of time that the animation should be delayed.

Cmn
Int

Duration of the animation in milliseconds.

Cmn

Public constructors

KeyframesSpecConfig

<T : Any?> KeyframesSpecConfig()

Public functions

at

infix fun T.at(timeStamp: Int): KeyframesSpec.KeyframeEntity<T>

Adds a keyframe so that animation value will be this at time: timeStamp. For example: 0.8f at 150 // ms

Parameters
timeStamp: Int

The time in the during when animation should reach value: this, with a minimum value of 0.

Returns
KeyframesSpec.KeyframeEntity<T>

an KeyframeEntity so a custom Easing can be added by with method.

atFraction

infix fun T.atFraction(fraction: Float): KeyframesSpec.KeyframeEntity<T>

Adds a keyframe so that the animation value will be the value specified at a fraction of the total durationMillis set. For example: 0.8f atFraction 0.50f // half of the overall duration set

Parameters
fraction: Float

The fraction when the animation should reach specified value.

Returns
KeyframesSpec.KeyframeEntity<T>

an KeyframeEntity so a custom Easing can be added by with method

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

with

infix fun KeyframesSpec.KeyframeEntity<T>.with(easing: Easing): Unit

Adds an Easing for the interval started with the just provided timestamp. For example: 0f at 50 with LinearEasing

import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.keyframes

// Use FastOutSlowInEasing for the interval from 0 to 50 ms, and LinearOutSlowInEasing for the
// time between 50 and 100ms
keyframes<Float> {
    durationMillis = 100
    0f at 0 with FastOutSlowInEasing
    1.5f at 50 with LinearOutSlowInEasing
    1f at 100
}
Parameters
easing: Easing

Easing to be used for the next interval.

Public properties

delayMillis

var delayMillisInt

The amount of time that the animation should be delayed. The minimum is 0 and defaults to 0.

durationMillis

var durationMillisInt

Duration of the animation in milliseconds. The minimum is 0 and defaults to DefaultDurationMillis