@JvmDefaultWithCompatibility
public interface Animation<T, V : AnimationVector>
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.
Properties
durationNanos
public val durationNanos: Long
This amount of time in nanoseconds that the animation will run before it finishes
typeConverter
public 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).
targetValue
public val targetValue: T
This is the value that the Animation will reach when it finishes uninterrupted.
isInfinite
public 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.
Functions
getValueFromNanos
public fun getValueFromNanos(playTimeNanos: Long): T
Returns the value of the animation at the given play time.
Parameters
| playTimeNanos | the play time that is used to determine the value of the animation. |
getVelocityVectorFromNanos
public fun getVelocityVectorFromNanos(playTimeNanos: Long): V
Returns the velocity (in AnimationVector form) of the animation at the given play time.
Parameters
| playTimeNanos | the play time that is used to calculate the velocity of the animation. |
isFinishedFromNanos
public fun isFinishedFromNanos(playTimeNanos: Long): Boolean
Returns whether the animation is finished at the given play time.
Parameters
| playTimeNanos | the play time used to determine whether the animation is finished. |