# AnimationState

Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/AnimationState.kt+class:androidx.compose.animation.core.AnimationState) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0) Common/All
- Cmn

  ```
  class AnimationState<T : Any?, V : AnimationVector> : State<T>
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` contains the necessary information to indicate the state of an animation. Once an `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` is constructed, it can only be updated/mutated by animations. If there's a need to mutate some of the fields of an `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, consider using `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).copy(kotlin.Any,androidx.compose.animation.core.AnimationVector,kotlin.Long,kotlin.Long,kotlin.Boolean)` functions.

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#AnimationState(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector,kotlin.Long,kotlin.Long,kotlin.Boolean)( typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V?, lastFrameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, finishedTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, isRunning: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#finishedTimeNanos()` The time when the animation finished successfully in the System.nanoTime timebase. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#isRunning()` Indicates whether the animation is currently running. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#lastFrameTimeNanos()` Last frame time of the animation. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#typeConverter()` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` to convert type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` | Cmn |
| `open T` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#value()` Current value of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`. | Cmn |
| `T` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#velocity()` Velocity of type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, converted from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#velocityVector()`. | Cmn |
| `V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#velocityVector()` Current velocity vector of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D>` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#(androidx.compose.animation.core.AnimationState).copy(kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Long,kotlin.Boolean)( value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, velocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, lastFrameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, finishedTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, isRunning: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates a new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` of Float `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).copy(kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Long,kotlin.Boolean)` type from a given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` of the same type. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<T, V>` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<T, V>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#(androidx.compose.animation.core.AnimationState).copy(kotlin.Any,androidx.compose.animation.core.AnimationVector,kotlin.Long,kotlin.Long,kotlin.Boolean)( value: T, velocityVector: V?, lastFrameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, finishedTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, isRunning: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates a new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` from a given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<T, V>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#(androidx.compose.animation.core.AnimationState).animateDecay(androidx.compose.animation.core.DecayAnimationSpec,kotlin.Boolean,kotlin.Function1)( animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<T>, sequentialAnimation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, block: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope<T, V>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Decay animation that slows down from the current velocity and value captured in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` until the velocity reaches 0. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<T, V>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)( targetValue: T, animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<T>, sequentialAnimation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, block: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope<T, V>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Target based animation that takes the value and velocity from the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` as the starting condition, and animate to the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)`, using the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)`. | Cmn |

| ### Extension properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<*, *>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#(androidx.compose.animation.core.AnimationState).isFinished()` Indicates whether the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` is for an animation that has finished, indicated by `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#finishedTimeNanos()` having a specified value. | Cmn |

## Public constructors

### AnimationState

Cmn

```
<T : Any?, V : AnimationVector> AnimationState(
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V? = null,
    lastFrameTimeNanos: Long = AnimationConstants.UnspecifiedTime,
    finishedTimeNanos: Long = AnimationConstants.UnspecifiedTime,
    isRunning: Boolean = false
)
```

| Parameters |
|---|---|
| `typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` to convert type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` |
| `initialValue: T` | initial value of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` |
| `initialVelocityVector: V? = null` | initial velocity of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, null (i.e. no velocity) by default. |
| `lastFrameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = AnimationConstants.UnspecifiedTime` | last frame time of the animation, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()` by default |
| `finishedTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = AnimationConstants.UnspecifiedTime` | the time that the animation finished successfully, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()` until then |
| `isRunning: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | whether the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` is currently being updated by an animation. False by default |

## Public functions

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### finishedTimeNanos

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val finishedTimeNanos: 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 `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()`, unless specified otherwise in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` constructor.

### isRunning

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val isRunning: Boolean
```

Indicates whether the animation is currently running.

### lastFrameTimeNanos

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val lastFrameTimeNanos: Long
```

Last frame time of the animation.

If the animation has never started, this will be `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()`, unless specified otherwise in the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` constructor. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#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 `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)`. This allows the sequential animation to set its start time to when the previous animation is interrupted or finished.

### typeConverter

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val typeConverter: TwoWayConverter<T, V>
```

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` to convert type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`

### value

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
open val value: T
```

Current value of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`.

### velocity

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val velocity: T
```

Velocity of type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, converted from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#velocityVector()`.

### velocityVector

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val velocityVector: V
```

Current velocity vector of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`.

## Extension functions

### AnimationState.copy

Cmn Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/AnimationState.kt+function:copy)

```
fun 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
): AnimationState<Float, AnimationVector1D>
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` of Float `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).copy(kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Long,kotlin.Boolean)` type from a given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` of the same type. This function allows some of the fields to be different in the new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = this.value` | value of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, using the value of the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default |
| `velocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = this.velocityVector.value` | velocity of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, using the velocity of the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default. |
| `lastFrameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = this.lastFrameTimeNanos` | last frame time of the animation, same as the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default |
| `finishedTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = this.finishedTimeNanos` | the time that the animation finished successfully, same as the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default. |
| `isRunning: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = this.isRunning` | whether the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` is currently being updated by an animation. Same as the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D>` | A new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` instance copied from the given instance, with some fields optionally altered |

### AnimationState.copy

Cmn Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/AnimationState.kt+function:copy)

```
fun <T : Any?, V : AnimationVector> 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
): AnimationState<T, V>
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` from a given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`. This function allows some of the fields to be different in the new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`.

| Parameters |
|---|---|
| `value: T = this.value` | value of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, using the value of the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default |
| `velocityVector: V? = this.velocityVector.copy()` | velocity of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`, using the velocity of the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default. |
| `lastFrameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = this.lastFrameTimeNanos` | last frame time of the animation, same as the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default |
| `finishedTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = this.finishedTimeNanos` | the time that the animation finished successfully, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()` until then. Default value is the same as the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState`. |
| `isRunning: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = this.isRunning` | whether the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` is currently being updated by an animation. Same as the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` by default |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState<T, V>` | A new `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` instance copied from the given instance, with some fields optionally altered |

### AnimationState.animateDecay

Cmn Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/SuspendAnimation.kt+function:animateDecay)

```
suspend fun <T : Any?, V : AnimationVector> AnimationState<T, V>.animateDecay(
    animationSpec: DecayAnimationSpec<T>,
    sequentialAnimation: Boolean = false,
    block: AnimationScope<T, V>.() -> Unit = {}
): Unit
```

Decay animation that slows down from the current velocity and value captured in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` until the velocity reaches 0. During the animation, the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` will be updated with the up-to-date value/velocity, frame time, etc. This is often used to animate the result of a fling gesture.

| Parameters |
|---|---|
| `animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<T>` | Defines the decay animation that will be used for this animation. Some options for `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateDecay(androidx.compose.animation.core.DecayAnimationSpec,kotlin.Boolean,kotlin.Function1)` include: `https://developer.android.com/reference/kotlin/androidx/compose/animation/package-summary#splineBasedDecay(androidx.compose.ui.unit.Density)` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#exponentialDecay(kotlin.Float,kotlin.Float)`. |
| `sequentialAnimation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | Indicates whether the animation should use the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#lastFrameTimeNanos()` as the starting time (if true), or start in a new frame. By default, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateDecay(androidx.compose.animation.core.DecayAnimationSpec,kotlin.Boolean,kotlin.Function1)` is false, to start the animation in a few frame. In cases where an on-going animation is interrupted and a new animation is started to carry over the momentum, using the interruption time (captured in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#lastFrameTimeNanos()`) creates a smoother animation. |
| `block: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope<T, V>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | will be invoked on every frame during the animation, and the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope` will be checked against cancellation before the animation continues. To cancel the animation from the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateDecay(androidx.compose.animation.core.DecayAnimationSpec,kotlin.Boolean,kotlin.Function1)`, simply call `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#cancelAnimation()`. After `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#cancelAnimation()` is called, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateDecay(androidx.compose.animation.core.DecayAnimationSpec,kotlin.Boolean,kotlin.Function1)` will not be invoked again. The animation loop will exit after the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateDecay(androidx.compose.animation.core.DecayAnimationSpec,kotlin.Boolean,kotlin.Function1)` returns. All the animation related info can be accessed via `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope`. |

### AnimationState.animateTo

Cmn Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/SuspendAnimation.kt+function:animateTo)

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

Target based animation that takes the value and velocity from the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` as the starting condition, and animate to the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)`, using the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)`. During the animation, the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` will be updated with the up-to-date value/velocity, frame time, etc.

```kotlin
import androidx.compose.animation.core.AnimationState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animate
import androidx.compose.animation.core.animateTo
import androidx.compose.animation.core.isFinished
import androidx.compose.animation.core.spring
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember

@Composable
fun simpleAnimate(target: Float): Float {
    // Create an AnimationState to be updated by the animation.
    val animationState = remember { AnimationState(target) }

    // Launch the suspend animation into the composition's CoroutineContext, and pass
    // `target` to LaunchedEffect so that when`target` changes the old animation job is
    // canceled, and a new animation is created with a new target.
    LaunchedEffect(target) {
        // This starts an animation that updates the animationState on each frame
        animationState.animateTo(
            targetValue = target,
            // Use a low stiffness spring. This can be replaced with any type of `AnimationSpec`
            animationSpec = spring(stiffness = Spring.StiffnessLow),
            // If the previous animation was interrupted (i.e. not finished), configure the
            // animation as a sequential animation to continue from the time the animation was
            // interrupted.
            sequentialAnimation = !animationState.isFinished,
        )
        // When the function above returns, the animation has finished.
    }
    // Return the value updated by the animation.
    return animationState.value
}
```

| Parameters |
|---|---|
| `targetValue: T` | The target value that the animation will animate to. |
| `animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<T> = spring()` | The animation configuration that will be used. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#spring(kotlin.Float,kotlin.Float,kotlin.Any)` by default. |
| `sequentialAnimation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | Indicates whether the animation should use the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#lastFrameTimeNanos()` as the starting time (if true), or start in a new frame. By default, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)` is false, to start the animation in a few frame. In cases where an on-going animation is interrupted and a new animation is started to carry over the momentum, using the interruption time (captured in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#lastFrameTimeNanos()`) creates a smoother animation. |
| `block: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope<T, V>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | Will be invoked on every frame, and the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope` will be checked against cancellation before the animation continues. To cancel the animation from the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)`, simply call `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#cancelAnimation()`. After `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#cancelAnimation()` is called, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)` will not be invoked again. The animation loop will exit after the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)` returns. All the animation related info can be accessed via `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope`. |

## Extension properties

### AnimationState.isFinished

Cmn Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/AnimationState.kt+symbol:isFinished) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val AnimationState<*, *>.isFinished: Boolean
```

Indicates whether the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` is for an animation that has finished, indicated by `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState#finishedTimeNanos()` having a specified value.