Animation
-
Cmn
interface Animation<T : Any?, V : AnimationVector>
DecayAnimation |
|
TargetBasedAnimation |
This is a convenient animation wrapper class that works for all target based animations, i.e. animations that has a pre-defined end value, unlike decay. |
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 Transition are stateful and manage their own lifecycles.
| See also | |
|---|---|
Animatable |
|
rememberTransition |
|
updateTransition |
Summary
Public functions |
||
|---|---|---|
T |
getValueFromNanos(playTimeNanos: Long)Returns the value of the animation at the given play time. |
Cmn
|
V |
getVelocityVectorFromNanos(playTimeNanos: Long)Returns the velocity (in |
Cmn
|
open Boolean |
isFinishedFromNanos(playTimeNanos: Long)Returns whether the animation is finished at the given play time. |
Cmn
|
Public properties |
||
|---|---|---|
Long |
This amount of time in nanoseconds that the animation will run before it finishes |
Cmn
|
Boolean |
Whether or not the |
Cmn
|
T |
This is the value that the |
Cmn
|
TwoWayConverter<T, V> |
The |
Cmn
|
Extension functions |
||
|---|---|---|
T |
<T : Any?, V : AnimationVector> Animation<T, V>.getVelocityFromNanos(Returns the velocity of the animation at the given play time. |
Cmn
|
Public functions
getValueFromNanos
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
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. |
isFinishedFromNanos
open fun isFinishedFromNanos(playTimeNanos: Long): Boolean
Returns whether the animation is finished at the given play time.
| Parameters | |
|---|---|
playTimeNanos: Long |
the play time used to determine whether the animation is finished. |
Public properties
durationNanos
val durationNanos: Long
This amount of time in nanoseconds that the animation will run before it finishes
isInfinite
val isInfinite: Boolean
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
val targetValue: T
This is the value that the Animation will reach when it finishes uninterrupted.
typeConverter
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).
Extension functions
Animation.getVelocityFromNanos
fun <T : Any?, V : AnimationVector> Animation<T, V>.getVelocityFromNanos(
playTimeNanos: Long
): T
Returns the velocity of the animation at the given play time.
| Parameters | |
|---|---|
playTimeNanos: Long |
the play time that is used to calculate the velocity of the animation. |