---
title: "animateDecay"
description: "Decay animation that slows down from the given [initialVelocity] starting at [initialValue] until
the velocity reaches 0. This is often used after a fling gesture.

This is a convenient method for decay animation. If there's a need to access more info related to
the animation such as start time, target, etc, consider using [AnimationState.animateDecay]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
public suspend fun animateDecay(
    initialValue: Float,
    initialVelocity: Float,
    animationSpec: FloatDecayAnimationSpec,
    block: (value: Float, velocity: Float) -> Unit,
)
```


Decay animation that slows down from the given `initialVelocity` starting at `initialValue` until
the velocity reaches 0. This is often used after a fling gesture.

This is a convenient method for decay animation. If there's a need to access more info related to
the animation such as start time, target, etc, consider using `AnimationState.animateDecay`.

#### Parameters

| | |
| --- | --- |
| initialValue | The initial value to animate from. |
| initialVelocity | The initial velocity of the animation. |
| animationSpec | Defines the decay animation that will be used for this animation. Some options for this `animationSpec` include: `splineBasedDecay` and `exponentialDecay`. |
| block | Will be invoked on each animation frame with up-to-date value and velocity. |




<div class='sourceset sourceset-common'>Common</div>


```kotlin
public suspend fun <T, V : AnimationVector> 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. During the animation, the given `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 | Defines the decay animation that will be used for this animation. Some options for `animationSpec` include: `splineBasedDecay` and `exponentialDecay`. |
| sequentialAnimation | Indicates whether the animation should use the `AnimationState.lastFrameTimeNanos` as the starting time (if true), or start in a new frame. By default, `sequentialAnimation` 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 `AnimationState.lastFrameTimeNanos`) creates a smoother animation. |
| block | will be invoked on every frame during the animation, and the `AnimationScope` will be checked against cancellation before the animation continues. To cancel the animation from the `block`, simply call `AnimationScope.cancelAnimation`. After `AnimationScope.cancelAnimation` is called, `block` will not be invoked again. The animation loop will exit after the `block` returns. All the animation related info can be accessed via `AnimationScope`. |




