# DecayAnimation

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/Animation.kt+class:androidx.compose.animation.core.DecayAnimation) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0) Common/All
- Cmn

  ```
  class DecayAnimation<T : Any?, V : AnimationVector> : Animation<T, V>
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is an animation that slows down from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.VectorizedDecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)` as time goes on. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` stores all the animation related information: `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#initialValue()`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.VectorizedDecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)`, decay animation spec, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#typeConverter()`.

**Note** : Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation`, such as `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animatable#animateDecay(kotlin.Any,androidx.compose.animation.core.DecayAnimationSpec,kotlin.Function1)`, `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)`, etc.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animatable#animateDecay(kotlin.Any,androidx.compose.animation.core.DecayAnimationSpec,kotlin.Function1)` |   |
| `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)` |   |

## 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/DecayAnimation#DecayAnimation(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)( animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<T>, typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>, initialValue: T, initialVelocity: T )` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is an animation that slows down from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` as time goes on. | Cmn |
| `<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/DecayAnimation#DecayAnimation(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)( animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<T>, typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V )` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is an animation that slows down from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)` as time goes on. | Cmn |
| `<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/DecayAnimation#DecayAnimation(androidx.compose.animation.core.VectorizedDecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)( animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec<V>, typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V )` | Cmn |

| ### Public functions |
|---|---|---|
| `open T` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#getValueFromNanos(kotlin.Long)(playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the value of the animation at the given play time. | Cmn |
| `open V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#getVelocityVectorFromNanos(kotlin.Long)(playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the velocity (in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` form) of the animation at the given play time. | Cmn |

| ### Public properties |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#durationNanos()` This amount of time in nanoseconds that the animation will run before it finishes | Cmn |
| `T` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#initialValue()` | Cmn |
| `V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#initialVelocityVector()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#isInfinite()` Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation` represents an infinite animation. | Cmn |
| `open T` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#targetValue()` This is the value that the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation` will reach when it finishes uninterrupted. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#typeConverter()` The `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` that will be used to convert value/velocity from any arbitrary data type to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`. | Cmn |

### Inherited functions

From [androidx.compose.animation.core.Animation](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation#isFinishedFromNanos(kotlin.Long)(playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Returns whether the animation is finished at the given play time.
Cmn

## Public constructors

### DecayAnimation

Cmn

```
<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocity: T
)
```

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is an animation that slows down from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` as time goes on. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` stores all the animation related information: `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)`.

**Note** : Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation`, such as `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animatable#animateDecay(kotlin.Any,androidx.compose.animation.core.DecayAnimationSpec,kotlin.Function1)`, `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)`, etc.

| Parameters |
|---|---|
| `animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<T>` | Decay animation spec that defines the slow-down curve of the animation |
| `typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | Type converter to convert the type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` |
| `initialValue: T` | The starting value of the animation |
| `initialVelocity: T` | The starting velocity of the animation |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animatable#animateDecay(kotlin.Any,androidx.compose.animation.core.DecayAnimationSpec,kotlin.Function1)` |   |
| `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)` |   |

### DecayAnimation

Cmn

```
<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V
)
```

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is an animation that slows down from `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)` as time goes on. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` stores all the animation related information: `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)`, decay animation spec, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation#(androidx.compose.animation.core.DecayAnimationSpec,androidx.compose.animation.core.TwoWayConverter,kotlin.Any,androidx.compose.animation.core.AnimationVector)`.

**Note** : Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation`, such as `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animatable#animateDecay(kotlin.Any,androidx.compose.animation.core.DecayAnimationSpec,kotlin.Function1)`, `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)`, etc.

| Parameters |
|---|---|
| `animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<T>` | Decay animation spec that defines the slow-down curve of the animation |
| `typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | Type converter to convert the type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` |
| `initialValue: T` | The starting value of the animation |
| `initialVelocityVector: V` | The starting velocity of the animation in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` form |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animatable#animateDecay(kotlin.Any,androidx.compose.animation.core.DecayAnimationSpec,kotlin.Function1)` |   |
| `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)` |   |

### DecayAnimation

Cmn

```
<T : Any?, V : AnimationVector> DecayAnimation(
    animationSpec: VectorizedDecayAnimationSpec<V>,
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocityVector: V
)
```

## Public functions

### getValueFromNanos

Cmn

```
open fun getValueFromNanos(playTimeNanos: Long): T
```

Returns the value of the animation at the given play time.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the play time that is used to determine the value of the animation. |

### getVelocityVectorFromNanos

Cmn

```
open fun getVelocityVectorFromNanos(playTimeNanos: Long): V
```

Returns the velocity (in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` form) of the animation at the given play time.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the play time that is used to calculate the velocity of the animation. |

## Public properties

### durationNanos

Cmn

```
open val durationNanos: Long
```

This amount of time in nanoseconds that the animation will run before it finishes

### initialValue

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

```
val initialValue: T
```

### initialVelocityVector

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

```
val initialVelocityVector: V
```

### isInfinite

Cmn

```
open val isInfinite: Boolean
```

Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/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.

### targetValue

Cmn

```
open val targetValue: T
```

This is the value that the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation` will reach when it finishes uninterrupted.

### typeConverter

Cmn

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

The `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` that will be used to convert value/velocity from any arbitrary data type to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`. This makes it possible to animate different dimensions of the data object independently (e.g. x/y dimensions of the position data).