Added in 1.11.0-rc01
public class AnimationState<T, V : AnimationVector>(
public val typeConverter: TwoWayConverter<T, V>,
initialValue: T,
initialVelocityVector: V? = null,
lastFrameTimeNanos: Long = AnimationConstants.UnspecifiedTime,
finishedTimeNanos: Long = AnimationConstants.UnspecifiedTime,
isRunning: Boolean = false,
) : State<T>
AnimationState contains the necessary information to indicate the state of an animation. Once an AnimationState is constructed, it can only be updated/mutated by animations. If there's a need to mutate some of the fields of an AnimationState, consider using copy functions.
Parameters
| typeConverter | TwoWayConverter to convert type T from and to AnimationVector |
| initialValue | initial value of the AnimationState |
| initialVelocityVector | initial velocity of the AnimationState, null (i.e. no velocity) by default. |
| lastFrameTimeNanos | last frame time of the animation, AnimationConstants.UnspecifiedTime by default |
| finishedTimeNanos | the time that the animation finished successfully, AnimationConstants.UnspecifiedTime until then |
| isRunning | whether the AnimationState is currently being updated by an animation. False by default |
Properties
velocityVector
Added in 1.11.0-rc01
public var velocityVector: V
Current velocity vector of the AnimationState.
lastFrameTimeNanos
Added in 1.11.0-rc01
public var : Long
Last frame time of the animation.
If the animation has never started, this will be AnimationConstants.UnspecifiedTime, unless specified otherwise in the AnimationState constructor. lastFrameTimeNanos is the frame time when the animation is last updated, in the System.nanoTime timebase. It is also used for starting a sequential animation in AnimationState.animateTo. This allows the sequential animation to set its start time to when the previous animation is interrupted or finished.
finishedTimeNanos
Added in 1.11.0-rc01
public var : Long
The time when the animation finished successfully in the System.nanoTime timebase.
If the animation has never finished (i.e. currently running, interrupted, or never started), this will be AnimationConstants.UnspecifiedTime, unless specified otherwise in AnimationState constructor.
isRunning
Added in 1.11.0-rc01
public var : Boolean
Indicates whether the animation is currently running.
velocity
Added in 1.11.0-rc01
public val velocity: T
Velocity of type T, converted from velocityVector.