# FollowMode

Artifact: [androidx.xr.compose:compose](https://developer.android.com/jetpack/androidx/releases/xr-compose) [View Source](https://cs.android.com/search?q=file:androidx/xr/compose/subspace/animation/follow/FollowMode.kt+class:androidx.xr.compose.subspace.animation.follow.FollowMode) Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)


```
@ExperimentalFollowingSubspaceApi
abstract class FollowMode
```

<br />

*** ** * ** ***

A FollowMode controls the motion of content as it is following another target. Currently, the options include "soft", which gradually catches up to the target and "snap", which does not continuously follow the target.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#snap(androidx.xr.compose.subspace.animation.follow.TrackedDimensions)(dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions)` Places content once based on the target's initial pose and does not follow subsequent movements. |
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` | `[soft](https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#soft(kotlin.Int,androidx.xr.compose.subspace.animation.follow.TrackedDimensions))(durationMs: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 100) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions)` **This function is deprecated.** durationMs is deprecated as follow motion is now based on exponential decay. |
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#soft(androidx.xr.compose.subspace.animation.follow.TrackedDimensions,kotlin.Long,kotlin.Long,androidx.xr.compose.subspace.animation.follow.FollowThresholds)( dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions, halfLifeMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, startDelay: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, startThresholds: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowThresholds )` Creates a mode where the content smoothly animates to follow the target's movements. |
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#tight(androidx.xr.compose.subspace.animation.follow.TrackedDimensions)(dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions)` Follows the target as closely as possible. |

| ### Protected properties |
|---|---|
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#dispatcherOverride()` |

## Public companion functions

### snap

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

```
fun snap(dimensions: TrackedDimensions = TrackedDimensions.All): FollowMode
```

Places content once based on the target's initial pose and does not follow subsequent movements.

| Parameters |
|---|---|
| `dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions = TrackedDimensions.All` | A set of boolean flags which determine the dimensions of movement that are tracked. By default, all dimensions are tracked. |

### soft

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

```
fun [soft](https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#soft(kotlin.Int,androidx.xr.compose.subspace.animation.follow.TrackedDimensions))(
    durationMs: @IntRange(from = 100) Int,
    dimensions: TrackedDimensions = TrackedDimensions.All
): FollowMode
```

> [!CAUTION]
> **This function is deprecated.**   
> durationMs is deprecated as follow motion is now based on exponential decay. Use halfLifeMillis instead, use this instead:
>
> ```kotlin
> FollowMode.soft(dimensions = dimensions)
> ```

Creates a mode where the content smoothly animates to follow the target's movements.

| Parameters |
|---|---|
| `durationMs: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 100) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Amount of milliseconds it takes for the content to catch up to the user. |
| `dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions = TrackedDimensions.All` | A set of boolean flags which determine the dimensions of movement that are tracked. By default, all dimensions are tracked. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` | A `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` instance configured for soft following. |

### soft

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

```
fun soft(
    dimensions: TrackedDimensions = TrackedDimensions.All,
    halfLifeMillis: @IntRange(from = 1) Long = SoftFollowMode.DEFAULT_HALF_LIFE_MILLIS,
    startDelay: @IntRange(from = 0) Long = SoftFollowMode.DEFAULT_START_DELAY,
    startThresholds: FollowThresholds = SoftFollowMode.DEFAULT_START_THRESHOLDS
): FollowMode
```

Creates a mode where the content smoothly animates to follow the target's movements.

This mode is driven by a first-order exponential decay model, which smoothly decelerates the trailing entity as it approaches the target.

| Parameters |
|---|---|
| `dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions = TrackedDimensions.All` | A set of boolean flags which determine the dimensions of movement that are tracked. Defaults to `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions#All()`. |
| `halfLifeMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = SoftFollowMode.DEFAULT_HALF_LIFE_MILLIS` | Time in milliseconds it takes for the content to cover half the distance to the target. Defaults to 175 milliseconds. |
| `startDelay: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = SoftFollowMode.DEFAULT_START_DELAY` | Time in milliseconds to wait before starting the follow movement. Defaults to 200 milliseconds. |
| `startThresholds: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowThresholds = SoftFollowMode.DEFAULT_START_THRESHOLDS` | A set of thresholds that must be exceeded before movement starts. Defaults to 0.2 meters of translation and 16 degrees of pitch, 24 degrees of yaw, and 20 degrees of roll. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` | A `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode` instance configured for soft following. |

### tight

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

```
fun tight(dimensions: TrackedDimensions = TrackedDimensions.All): FollowMode
```

Follows the target as closely as possible.

In contrast to `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#soft(androidx.xr.compose.subspace.animation.follow.TrackedDimensions,kotlin.Long,kotlin.Long,androidx.xr.compose.subspace.animation.follow.FollowThresholds)`, where the content lags behind the target, `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/FollowMode#tight(androidx.xr.compose.subspace.animation.follow.TrackedDimensions)` follow matches the target's movement instantly.

| Parameters |
|---|---|
| `dimensions: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/animation/follow/TrackedDimensions = TrackedDimensions.All` | A set of boolean flags which determine the dimensions of movement that are tracked. By default, all dimensions are tracked. |

## Protected properties

### dispatcherOverride

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

```
protected val dispatcherOverride: CoroutineDispatcher
```