Animation
interface Animation<T, V : AnimationVector>
androidx.compose.animation.core.Animation |
This interface provides a convenient way to query from an VectorizedAnimationSpec or FloatDecayAnimationSpec: It spares the need to pass the starting conditions and in some cases ending condition for each value or velocity query, and instead only requires the play time to be passed for such queries.
The implementation of this interface should cache the starting conditions and ending conditions of animations as needed.
Note: Animation does not track the lifecycle of an animation. It merely reacts to play time change and returns the new value/velocity as a result. It can be used as a building block for more lifecycle aware animations. In contrast, Animatable and TransitionAnimation are stateful and manage their own lifecycles, and subscribe/unsubscribe from an AnimationClockObservable as needed.
Summary
Public methods | |
---|---|
abstract T |
Returns the value of the animation at the given play time. |
abstract V |
getVelocityVector(playTime: Long) Returns the velocity (in AnimationVector form) of the animation at the given play time. |
open Boolean |
isFinished(playTime: Long) Returns whether the animation is finished at the given play time. |
Extension functions | ||
---|---|---|
From androidx.compose.animation.core
|
Properties | |
---|---|
open TwoWayConverter<T, V> | |
abstract Long |
This amount of time in milliseconds that the animation will run before it finishes |
abstract T |
This is the value that the Animation will reach when it finishes uninterrupted. |
abstract TwoWayConverter<T, V> |
The TwoWayConverter that will be used to convert value/velocity from any arbitrary data type to AnimationVector. |
Public methods
getValue
abstract fun getValue(playTime: Long): T
Returns the value of the animation at the given play time.
Parameters | |
---|---|
playTime: Long | the play time that is used to determine the value of the animation. |
getVelocityVector
abstract fun getVelocityVector(playTime: Long): V
Returns the velocity (in AnimationVector form) of the animation at the given play time.
Parameters | |
---|---|
playTime: Long | the play time that is used to calculate the velocity of the animation. |
isFinished
open fun isFinished(playTime: Long): Boolean
Returns whether the animation is finished at the given play time.
Parameters | |
---|---|
playTime: Long | the play time used to determine whether the animation is finished. |
Properties
durationMillis
abstract val durationMillis: Long
This amount of time in milliseconds that the animation will run before it finishes
targetValue
abstract val targetValue: T
This is the value that the Animation will reach when it finishes uninterrupted.
typeConverter
abstract val typeConverter: TwoWayConverter<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).