DecayAnimation


DecayAnimation is an animation that slows down from initialVelocityVector as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocityVector, decay animation spec, typeConverter.

Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.

Summary

Public constructors

<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocity: T
)

DecayAnimation is an animation that slows down from initialVelocity as time goes on.

Cmn
<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V
)

DecayAnimation is an animation that slows down from initialVelocityVector as time goes on.

Cmn
<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: VectorizedDecayAnimationSpec<V>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V
)
Cmn

Public functions

open T
getValueFromNanos(playTimeNanos: Long)

Returns the value of the animation at the given play time.

Cmn
open V

Returns the velocity (in AnimationVector form) of the animation at the given play time.

Cmn

Public properties

open Long

This amount of time in nanoseconds that the animation will run before it finishes

Cmn
T
Cmn
V
Cmn
open Boolean

Whether or not the Animation represents an infinite animation.

Cmn
open T

This is the value that the Animation will reach when it finishes uninterrupted.

Cmn
open TwoWayConverter<T, V>

The TwoWayConverter that will be used to convert value/velocity from any arbitrary data type to AnimationVector.

Cmn

Inherited functions

From androidx.compose.animation.core.Animation
open Boolean
isFinishedFromNanos(playTimeNanos: Long)

Returns whether the animation is finished at the given play time.

Cmn

Public constructors

DecayAnimation

<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocity: T
)

DecayAnimation is an animation that slows down from initialVelocity as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocity, animationSpec, typeConverter.

Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.

Parameters
animationSpec: DecayAnimationSpec<T>

Decay animation spec that defines the slow-down curve of the animation

typeConverter: TwoWayConverter<T, V>

Type converter to convert the type T from and to AnimationVector

initialValue: T

The starting value of the animation

initialVelocity: T

The starting velocity of the animation

DecayAnimation

<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V
)

DecayAnimation is an animation that slows down from initialVelocityVector as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocityVector, decay animation spec, typeConverter.

Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.

Parameters
animationSpec: DecayAnimationSpec<T>

Decay animation spec that defines the slow-down curve of the animation

typeConverter: TwoWayConverter<T, V>

Type converter to convert the type T from and to AnimationVector

initialValue: T

The starting value of the animation

initialVelocityVector: V

The starting velocity of the animation in AnimationVector form

DecayAnimation

<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: VectorizedDecayAnimationSpec<V>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V
)

Public functions

getValueFromNanos

open fun getValueFromNanos(playTimeNanos: Long): T

Returns the value of the animation at the given play time.

Parameters
playTimeNanos: Long

the play time that is used to determine the value of the animation.

getVelocityVectorFromNanos

open fun getVelocityVectorFromNanos(playTimeNanos: Long): V

Returns the velocity (in AnimationVector form) of the animation at the given play time.

Parameters
playTimeNanos: Long

the play time that is used to calculate the velocity of the animation.

Public properties

durationNanos

open val durationNanosLong

This amount of time in nanoseconds that the animation will run before it finishes

initialValue

val initialValue: T

initialVelocityVector

val initialVelocityVector: V

isInfinite

open val isInfiniteBoolean

Whether or not the Animation represents an infinite animation. That is, one that will not finish by itself, one that needs an external action to stop. For examples, an indeterminate progress bar, which will only stop when it is removed from the composition.

targetValue

open val targetValue: T

This is the value that the Animation will reach when it finishes uninterrupted.

typeConverter

open val typeConverterTwoWayConverter<T, V>

The TwoWayConverter that will be used to convert value/velocity from any arbitrary data type to AnimationVector. This makes it possible to animate different dimensions of the data object independently (e.g. x/y dimensions of the position data).