# DecayAnimationSpec

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

  ```
  interface DecayAnimationSpec<T : Any?>
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec` stores the specification of an animation, including 1) the data type to be animated, and 2) the animation configuration (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec`) that will be used once the data (of type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec`) has been converted to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`.

Any type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec` can be animated by the system as long as a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` is supplied to convert the data type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec` from and to an `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`. There are a number of converters available out of the box. For example, to animate `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset` the system uses `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.ui.unit.IntOffset.Companion).VectorConverter()` to convert the object to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector2D`, so that both x and y dimensions are animated independently with separate velocity tracking. This enables multidimensional objects to be animated in a true multi-dimensional way. It is particularly useful for smoothly handling animation interruptions (such as when the target changes during the animation).

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec<V>` | `<V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec#vectorize(androidx.compose.animation.core.TwoWayConverter)(typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>)` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec` with the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(kotlin.Float,kotlin.Float)( initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Calculates the target value of a Float decay animation based on the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(kotlin.Float,kotlin.Float)` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(kotlin.Float,kotlin.Float)`. | Cmn |
| `T` | `<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/DecayAnimationSpec<T>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)( typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>, initialValue: T, initialVelocity: T )` Calculates the target value of a decay animation based on the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)`, and the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` that converts the given type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`. | Cmn |

## Public functions

### vectorize

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

```
fun <V : AnimationVector> vectorize(typeConverter: TwoWayConverter<T, V>): VectorizedDecayAnimationSpec<V>
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec` with the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`.

The underlying animation system operates on `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`s. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec` will be converted to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` to animate. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec` describes how the converted `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` should be animated.

| Parameters |
|---|---|
| `typeConverter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | converts the type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` type |

## Extension functions

### DecayAnimationSpec.calculateTargetValue

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/DecayAnimationSpec.kt+function:calculateTargetValue)

```
fun DecayAnimationSpec<Float>.calculateTargetValue(
    initialValue: Float,
    initialVelocity: Float
): Float
```

Calculates the target value of a Float decay animation based on the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(kotlin.Float,kotlin.Float)` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(kotlin.Float,kotlin.Float)`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | target value where the animation will come to a natural stop |

### DecayAnimationSpec.calculateTargetValue

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/DecayAnimationSpec.kt+function:calculateTargetValue)

```
fun <T : Any?, V : AnimationVector> DecayAnimationSpec<T>.calculateTargetValue(
    typeConverter: TwoWayConverter<T, V>,
    initialValue: T,
    initialVelocity: T
): T
```

Calculates the target value of a decay animation based on the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)`, and the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` that converts the given type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.DecayAnimationSpec).calculateTargetValue(androidx.compose.animation.core.TwoWayConverter,kotlin.Any,kotlin.Any)` to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`.

| Returns |
|---|---|
| `T` | target value where the animation will come to a natural stop |