DecayAnimation

class DecayAnimation<T, V : AnimationVector>(animationSpec: VectorizedDecayAnimationSpec<V>, val typeConverter: TwoWayConverter<T, V>, val initialValue: T, initialVelocityVector: V) : Animation<T, 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 com.jakewharton.mosaic.animation.Animatable.animateDecay, com.jakewharton.mosaic.animation.animateDecay, etc.

See also

Constructors

Link copied to clipboard
constructor(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.

constructor(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.

constructor(animationSpec: VectorizedDecayAnimationSpec<V>, typeConverter: TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V)

Properties

Link copied to clipboard
open override val durationNanos: Long

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

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val isInfinite: Boolean = false

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.

Link copied to clipboard
open override val targetValue: T

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

Link copied to clipboard
open override val typeConverter: TwoWayConverter<T, V>

The com.jakewharton.mosaic.animation.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).

Functions

Link copied to clipboard
open override fun getValueFromNanos(playTimeNanos: Long): T

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

Link copied to clipboard
fun <T, V : AnimationVector> Animation<T, V>.getVelocityFromNanos(playTimeNanos: Long): T

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

Link copied to clipboard
open override fun getVelocityVectorFromNanos(playTimeNanos: Long): V

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

Link copied to clipboard
open fun isFinishedFromNanos(playTimeNanos: Long): Boolean

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