# InfiniteRepeatableSpec

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

  ```
  class InfiniteRepeatableSpec<T : Any?> : AnimationSpec<T>
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec` repeats the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#(androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` infinite amount of times. It will never naturally finish. This means the animation will only be stopped via some form of manual cancellation. When used with transition or other animation composables, the infinite animations will stop when the composable is removed from the compose tree.

For non-infinite repeating animations, consider `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatableSpec`.

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#(androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` 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/InfiniteRepeatableSpec#(androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` (if any) will be repeated. By default, the amount of offset is 0.

```kotlin
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.StartOffset
import androidx.compose.animation.core.StartOffsetType
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp

// This is an infinite progress indicator with 3 pulsing dots that grow and shrink.
@Composable
fun Dot(scale: State<Float>) {
    Box(
        Modifier.padding(5.dp)
            .size(20.dp)
            .graphicsLayer {
                scaleX = scale.value
                scaleY = scale.value
            }
            .background(Color.Gray, shape = CircleShape)
    )
}

val infiniteTransition = rememberInfiniteTransition()
val scale1 =
    infiniteTransition.animateFloat(
        0.2f,
        1f,
        // No offset for the 1st animation
        infiniteRepeatable(tween(600), RepeatMode.Reverse),
    )
val scale2 =
    infiniteTransition.animateFloat(
        0.2f,
        1f,
        infiniteRepeatable(
            tween(600),
            RepeatMode.Reverse,
            // Offsets the 2nd animation by starting from 150ms of the animation
            // This offset will not be repeated.
            initialStartOffset = StartOffset(offsetMillis = 150, StartOffsetType.FastForward),
        ),
    )
val scale3 =
    infiniteTransition.animateFloat(
        0.2f,
        1f,
        infiniteRepeatable(
            tween(600),
            RepeatMode.Reverse,
            // Offsets the 3rd animation by starting from 300ms of the animation. This
            // offset will be not repeated.
            initialStartOffset = StartOffset(offsetMillis = 300, StartOffsetType.FastForward),
        ),
    )
Row {
    Dot(scale1)
    Dot(scale2)
    Dot(scale3)
}
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` |   |

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#InfiniteRepeatableSpec(androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)( animation: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec<T>, 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 operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#hashCode()()` | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec<V>` | `<V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#vectorize(androidx.compose.animation.core.TwoWayConverter)(converter: 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/VectorizedAnimationSpec` with the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#animation()` the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` to be repeated | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#initialStartOffset()` offsets the start of the animation | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatMode` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#repeatMode()` 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`) | Cmn |

## Public constructors

### InfiniteRepeatableSpec

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

```
<T : Any?> InfiniteRepeatableSpec(
    animation: DurationBasedAnimationSpec<T>,
    repeatMode: RepeatMode = RepeatMode.Restart,
    initialStartOffset: StartOffset = StartOffset(0)
)
```

| Parameters |
|---|---|
| `animation: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec<T>` | the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` to be repeated |
| `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

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### vectorize

Cmn

```
open fun <V : AnimationVector> vectorize(converter: TwoWayConverter<T, V>): VectorizedAnimationSpec<V>
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` 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/AnimationSpec` 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/VectorizedAnimationSpec` describes how the converted `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` should be animated. E.g. The animation could simply interpolate between the start and end values (i.e.`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TweenSpec`), or apply spring physics to produce the motion (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec`), etc)

| Parameters |
|---|---|
| `converter: 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/AnimationSpec` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` type |

## Public properties

### animation

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

```
val animation: DurationBasedAnimationSpec<T>
```

the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` to be repeated

### initialStartOffset

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

```
val initialStartOffset: StartOffset
```

offsets the start of the animation

### repeatMode

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

```
val repeatMode: RepeatMode
```

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`)