# VectorizedRepeatableSpec

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

  ```
  class VectorizedRepeatableSpec<V : AnimationVector> : VectorizedFiniteAnimationSpec<V>
  ```

*** ** * ** ***

This animation takes another `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec` and plays it `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#(kotlin.Int,androidx.compose.animation.core.VectorizedDurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` times. For infinitely repeating animation spec, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedInfiniteRepeatableSpec` is recommended.

**Note** : When repeating in the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatMode#Reverse` mode, it's highly recommended to have an **odd** number of iterations. Otherwise, the animation may jump to the end value when it finishes the last iteration.

initialStartOffset can be used to either delay the start of the animation or to fast forward the animation to a given play time. This start offset will **not** be repeated, whereas the delay in the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#(kotlin.Int,androidx.compose.animation.core.VectorizedDurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` (if any) will be repeated. By default, the amount of offset is 0.

## Summary

| ### Public constructors |
|---|---|
| `<V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#VectorizedRepeatableSpec(kotlin.Int,androidx.compose.animation.core.VectorizedDurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)( iterations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, animation: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec<V>, repeatMode: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatMode, initialStartOffset: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset )` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)(initialValue: V, targetValue: V, initialVelocity: V)` Calculates the duration of an animation. | Cmn |
| `open V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#getValueFromNanos(kotlin.Long,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)( playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initialValue: V, targetValue: V, initialVelocity: V )` Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity. | Cmn |
| `open V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#getVelocityFromNanos(kotlin.Long,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)( playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initialValue: V, targetValue: V, initialVelocity: V )` Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity. | Cmn |

### Inherited functions

From [androidx.compose.animation.core.VectorizedAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec) `open V` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getEndVelocity(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)(initialValue: V, targetValue: V, initialVelocity: V)`

Calculates the end velocity of the animation with the provided start/end values, and start velocity.
Cmn

### Inherited properties

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

Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` specifies an infinite animation.
Cmn

## Public constructors

### VectorizedRepeatableSpec

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

```
<V : AnimationVector> VectorizedRepeatableSpec(
    iterations: Int,
    animation: VectorizedDurationBasedAnimationSpec<V>,
    repeatMode: RepeatMode = RepeatMode.Restart,
    initialStartOffset: StartOffset = StartOffset(0)
)
```

| Parameters |
|---|---|
| `iterations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the count of iterations. Should be at least 1. |
| `animation: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec<V>` | the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` describing each repetition iteration. |
| `repeatMode: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatMode = RepeatMode.Restart` | whether animation should repeat by starting from the beginning (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatMode#Restart`) or from the end (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatMode#Reverse`) |
| `initialStartOffset: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset = StartOffset(0)` | offsets the start of the animation |

## Public functions

### getDurationNanos

Cmn

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

Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)` values, and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)`.

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

### getValueFromNanos

Cmn

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

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | time since the start of the animation |
| `initialValue: V` | start value of the animation |
| `targetValue: V` | end value of the animation |
| `initialVelocity: V` | start velocity of the animation |

### getVelocityFromNanos

Cmn

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

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | time since the start of the animation |
| `initialValue: V` | start value of the animation |
| `targetValue: V` | end value of the animation |
| `initialVelocity: V` | start velocity of the animation |