DecayAnimation
-
Cmn
class DecayAnimation<T : Any?, V : AnimationVector> : Animation
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.
| See also | |
|---|---|
animateDecay |
|
animateDecay |
Summary
Public constructors |
|
|---|---|
<T : Any?, V : AnimationVector> DecayAnimation(
|
Cmn
|
<T : Any?, V : AnimationVector> DecayAnimation(
|
Cmn
|
<T : Any?, V : AnimationVector> DecayAnimation( |
Cmn
|
Public functions |
||
|---|---|---|
open T |
getValueFromNanos(playTimeNanos: Long)Returns the value of the animation at the given play time. |
Cmn
|
open V |
getVelocityVectorFromNanos(playTimeNanos: Long)Returns the velocity (in |
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 |
Cmn
|
open T |
This is the value that the |
Cmn
|
open TwoWayConverter<T, V> |
The |
Cmn
|
Inherited functions |
|||
|---|---|---|---|
|
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 |
initialValue: T |
The starting value of the animation |
initialVelocity: T |
The starting velocity of the animation |
| See also | |
|---|---|
animateDecay |
|
animateDecay |
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 |
initialValue: T |
The starting value of the animation |
initialVelocityVector: V |
The starting velocity of the animation in |
| See also | |
|---|---|
animateDecay |
|
animateDecay |
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 durationNanos: Long
This amount of time in nanoseconds that the animation will run before it finishes
isInfinite
open 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
open val targetValue: T
This is the value that the Animation will reach when it finishes uninterrupted.
typeConverter
open 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).