# StartOffset

# StartOffset

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.StartOffset)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.1.0)
Common/All
  - Cmn  

  ```
  value class StartOffset
  ```

*** ** * ** ***

This class defines a start offset for[repeatable](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#repeatable(kotlin.Int,androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset))and[infiniteRepeatable](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)). There are two types of start offsets:[StartOffsetType.Delay](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#Delay())and[StartOffsetType.FastForward](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#FastForward()).[StartOffsetType.Delay](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#Delay())delays the start of the animation, whereas[StartOffsetType.FastForward](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#FastForward())fast forwards the animation to a given play time and starts it right away.  

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

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [StartOffset](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#StartOffset(kotlin.Int,androidx.compose.animation.core.StartOffsetType))`(offsetMillis: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, offsetType: `[StartOffsetType](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType)`)` This creates a start offset for[repeatable](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#repeatable(kotlin.Int,androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset))and[infiniteRepeatable](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)). | Cmn |

|                                               ### Public properties                                               |
|-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                       | [offsetMillis](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#offsetMillis()) Returns the number of milliseconds to offset the start of the animation.                                                                      | Cmn |
| [StartOffsetType](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType) | [offsetType](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#offsetType()) Returns the offset type of the provided[StartOffset](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset). | Cmn |

## Public constructors

### StartOffset

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

```
StartOffset(
    offsetMillis: Int,
    offsetType: StartOffsetType = StartOffsetType.Delay
)
```

This creates a start offset for[repeatable](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#repeatable(kotlin.Int,androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset))and[infiniteRepeatable](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)).[offsetType](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#<init>(kotlin.Int,androidx.compose.animation.core.StartOffsetType))can be either of the following:[StartOffsetType.Delay](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#Delay())and[StartOffsetType.FastForward](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#FastForward()).[offsetType](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#<init>(kotlin.Int,androidx.compose.animation.core.StartOffsetType))defaults to[StartOffsetType.Delay](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#Delay()).

[StartOffsetType.Delay](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#Delay())delays the start of the animation by[offsetMillis](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#<init>(kotlin.Int,androidx.compose.animation.core.StartOffsetType)), whereas[StartOffsetType.FastForward](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffsetType#FastForward())starts the animation right away from[offsetMillis](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset#<init>(kotlin.Int,androidx.compose.animation.core.StartOffsetType))in the animation.

## Public properties

### offsetMillis

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

```
val offsetMillis: Int
```

Returns the number of milliseconds to offset the start of the animation.  

### offsetType

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

```
val offsetType: StartOffsetType
```

Returns the offset type of the provided[StartOffset](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/StartOffset).