# VectorizedDecayAnimationSpec

# VectorizedDecayAnimationSpec

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

  ```
  interface VectorizedDecayAnimationSpec<V : AnimationVector>
  ```

*** ** * ** ***

[VectorizedDecayAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec)s are stateless vector based decay animation specifications. They do not assume any starting/ending conditions. Nor do they manage a lifecycle. All it stores is the configuration that is particular to the type of the decay animation: friction multiplier for[exponentialDecay](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#exponentialDecay(kotlin.Float,kotlin.Float)). Its stateless nature allows the same[VectorizedDecayAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec)to be reused by a few different running animations with different starting and ending values.

Since[VectorizedDecayAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec)s are stateless, it requires starting value/velocity and ending value to be passed in, along with playtime, to calculate the value or velocity at that time. Play time here is the progress of the animation in terms of milliseconds, where 0 means the start of the animation and[getDurationNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector))returns the play time for the end of the animation.

**Note** : For use cases where the starting values/velocity and ending values aren't expected to change, it is recommended to use[DecayAnimation](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation)that caches these static values and hence does not require them to be supplied in the value/velocity calculation.  

|                                                    See also                                                     |
|-----------------------------------------------------------------------------------------------------------------|---|
| [DecayAnimation](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimation) |   |

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [getDurationNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector))`(initialValue: V, initialVelocity: V)` Returns the duration of the decay animation, in nanoseconds.                                                                                                                              | Cmn |
| `V`                                                                           | [getTargetValue](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec#getTargetValue(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector))`(initialValue: V, initialVelocity: V)` Returns the target value of the animation based on the initial condition of the animation ( i.e. initial value and initial velocity).                                                         | Cmn |
| `V`                                                                           | [getValueFromNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec#getValueFromNanos(kotlin.Long,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector))`(playTimeNanos: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, initialValue: V, initialVelocity: V)` Returns the value of the animation at the given time.                       | Cmn |
| `V`                                                                           | [getVelocityFromNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec#getVelocityFromNanos(kotlin.Long,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector))`(` ` playTimeNanos: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` initialValue: V,` ` initialVelocity: V` `)` Returns the velocity of the animation at the given time. | Cmn |

|                              ### Public properties                              |
|---------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [absVelocityThreshold](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDecayAnimationSpec#absVelocityThreshold()) This is the absolute value of a velocity threshold, below which the animation is considered finished. | Cmn |

## Public functions

### getDurationNanos

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

```
fun getDurationNanos(initialValue: V, initialVelocity: V): Long
```

Returns the duration of the decay animation, in nanoseconds.  

|      Parameters      |
|----------------------|----------------------------------------|
| `initialValue: V`    | initialValue value of the animation    |
| `initialVelocity: V` | initialValue velocity of the animation |

### getTargetValue

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

```
fun getTargetValue(initialValue: V, initialVelocity: V): V
```

Returns the target value of the animation based on the initial condition of the animation ( i.e. initial value and initial velocity).  

|      Parameters      |
|----------------------|---------------------------------------|
| `initialValue: V`    | The initial value of the animation    |
| `initialVelocity: V` | The initial velocity of the animation |

### getValueFromNanos

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

```
fun getValueFromNanos(playTimeNanos: Long, initialValue: V, initialVelocity: V): V
```

Returns the value of the animation at the given time.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| `playTimeNanos: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time elapsed in milliseconds since the initialValue of the animation |
| `initialValue: V`                                                                              | The initialValue value of the animation                                  |
| `initialVelocity: V`                                                                           | The initialValue velocity of the animation                               |

### getVelocityFromNanos

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

```
fun getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    initialVelocity: V
): V
```

Returns the velocity of the animation at the given time.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| `playTimeNanos: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time elapsed in milliseconds since the initialValue of the animation |
| `initialValue: V`                                                                              | The initialValue value of the animation                                  |
| `initialVelocity: V`                                                                           | The initialValue velocity of the animation                               |

## Public properties

### absVelocityThreshold

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

```
val absVelocityThreshold: Float
```

This is the absolute value of a velocity threshold, below which the animation is considered finished.