KeyframesSpecBaseConfig


Shared configuration class used as DSL for keyframe based animations.

Summary

Protected constructors

Cmn

Public functions

open infix E
T.at(timeStamp: @IntRange(from = 0) Int)

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

Cmn
open infix E
T.atFraction(fraction: @FloatRange(from = 0.0, to = 1.0) Float)

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

Cmn
infix E
E.using(easing: Easing)

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

Protected constructors

KeyframesSpecBaseConfig

protected <T : Any?, E : KeyframeBaseEntity<T>> KeyframesSpecBaseConfig()

Public functions

open infix fun T.at(timeStamp: @IntRange(from = 0) Int): E

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

0.8f at 150 // ms
Parameters
timeStamp: @IntRange(from = 0) Int

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

Returns
E

an instance of E so a custom Easing can be added by the using method.

atFraction

open infix fun T.atFraction(fraction: @FloatRange(from = 0.0, to = 1.0) Float): E

Adds a keyframe so that the animation value will be the value specified at a fraction of the total durationMillis set. It's recommended that you always set durationMillis before calling atFraction. For example:

// Make sure to set the duration before calling `atFraction` otherwise the keyframe will be set
// based on the default duration
durationMillis = 300
0.8f atFraction 0.50f // half of the overall duration set
Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float

The fraction when the animation should reach specified value.

Returns
E

an instance of E so a custom Easing can be added by the using method

infix fun E.using(easing: Easing): E

Adds an Easing for the interval started with the just provided timestamp. For example: 0f at 50 using 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 using FastOutSlowInEasing
    1.5f at 50 using LinearOutSlowInEasing
    1f at 100
}
Parameters
easing: Easing

Easing to be used for the next interval.

Returns
E

the same E instance so that other implementations can expand on the builder pattern

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