Android 12 Developer Preview is here! Try it out, and give us your feedback!

AnimationState

class AnimationState<T, V : AnimationVector> : State<T>
kotlin.Any
   ↳ androidx.compose.animation.core.AnimationState

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.

Summary

Public constructors
<init>(typeConverter: TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V? = null, lastFrameTimeNanos: Long = AnimationConstants.UnspecifiedTime, finishedTimeNanos: Long = AnimationConstants.UnspecifiedTime, isRunning: Boolean = false)

AnimationState contains the necessary information to indicate the state of an animation.

Extension functions
From androidx.compose.animation.core
suspend Unit
AnimationState<T, V>.animateDecay(animationSpec: DecayAnimationSpec<T>, sequentialAnimation: Boolean = false, block: AnimationScope<T, V>.() -> Unit = {})

Decay animation that slows down from the current velocity and value captured in AnimationState until the velocity reaches 0.

suspend Unit
AnimationState<T, V>.animateTo(targetValue: T, animationSpec: AnimationSpec<T> = spring(), sequentialAnimation: Boolean = false, block: AnimationScope<T, V>.() -> Unit = {})

Target based animation that takes the value and velocity from the AnimationState as the starting condition, and animate to the targetValue, using the animationSpec.

AnimationState<T, V>
AnimationState<T, V>.copy(value: T = this.value, velocityVector: V? = this.velocityVector.copy(), lastFrameTimeNanos: Long = this.lastFrameTimeNanos, finishedTimeNanos: Long = this.finishedTimeNanos, isRunning: Boolean = this.isRunning)

Creates a new AnimationState from a given AnimationState.

AnimationState<Float, AnimationVector1D>
AnimationState<Float, AnimationVector1D>.copy(value: Float = this.value, velocity: Float = this.velocityVector.value, lastFrameTimeNanos: Long = this.lastFrameTimeNanos, finishedTimeNanos: Long = this.finishedTimeNanos, isRunning: Boolean = this.isRunning)

Creates a new AnimationState of Float