# PagerSnapDistance

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/pager/PagerSnapDistance.kt+class:androidx.compose.foundation.pager.PagerSnapDistance) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.4.0) Common/All
- Cmn

  ```
  interface PagerSnapDistance
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/PagerSnapDistance` defines the way the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/package-summary#Pager(androidx.compose.ui.Modifier,androidx.compose.foundation.pager.PagerState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.gestures.Orientation,androidx.compose.foundation.gestures.TargetedFlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,kotlin.Int,androidx.compose.ui.unit.Dp,androidx.compose.foundation.pager.PageSize,androidx.compose.ui.input.nestedscroll.NestedScrollConnection,kotlin.Function1,androidx.compose.ui.Alignment.Horizontal,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.snapping.SnapPosition,androidx.compose.foundation.gestures.BringIntoViewSpec,kotlin.Function2)` will treat the distance between the current page and the page where it will settle.

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/PagerSnapDistance` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/PagerSnapDistance#atMost(kotlin.Int)(pages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Limits the maximum number of pages that can be flung per fling gesture. | Cmn |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/PagerSnapDistance#calculateTargetPage(kotlin.Int,kotlin.Int,kotlin.Float,kotlin.Int,kotlin.Int)( startPage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, suggestedTargetPage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, velocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pageSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, pageSpacing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Provides a chance to change where the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/package-summary#Pager(androidx.compose.ui.Modifier,androidx.compose.foundation.pager.PagerState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.gestures.Orientation,androidx.compose.foundation.gestures.TargetedFlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,kotlin.Int,androidx.compose.ui.unit.Dp,androidx.compose.foundation.pager.PageSize,androidx.compose.ui.input.nestedscroll.NestedScrollConnection,kotlin.Function1,androidx.compose.ui.Alignment.Horizontal,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.snapping.SnapPosition,androidx.compose.foundation.gestures.BringIntoViewSpec,kotlin.Function2)` fling will settle. | Cmn |

## Public companion functions

### atMost

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

```
fun atMost(pages: Int): PagerSnapDistance
```

Limits the maximum number of pages that can be flung per fling gesture.

| Parameters |
|---|---|
| `pages: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of extra pages that can be flung at once. |

## Public functions

### calculateTargetPage

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

```
fun calculateTargetPage(
    startPage: Int,
    suggestedTargetPage: Int,
    velocity: Float,
    pageSize: Int,
    pageSpacing: Int
): Int
```

Provides a chance to change where the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/package-summary#Pager(androidx.compose.ui.Modifier,androidx.compose.foundation.pager.PagerState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.gestures.Orientation,androidx.compose.foundation.gestures.TargetedFlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,kotlin.Int,androidx.compose.ui.unit.Dp,androidx.compose.foundation.pager.PageSize,androidx.compose.ui.input.nestedscroll.NestedScrollConnection,kotlin.Function1,androidx.compose.ui.Alignment.Horizontal,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.snapping.SnapPosition,androidx.compose.foundation.gestures.BringIntoViewSpec,kotlin.Function2)` fling will settle.

| Parameters |
|---|---|
| `startPage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The current page right before the fling starts. |
| `suggestedTargetPage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The proposed target page where this fling will stop. This target will be the page that will be correctly positioned (snapped) after naturally decaying with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/PagerSnapDistance#calculateTargetPage(kotlin.Int,kotlin.Int,kotlin.Float,kotlin.Int,kotlin.Int)` using a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DecayAnimationSpec`. |
| `velocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The initial fling velocity. |
| `pageSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The page size for this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/pager/package-summary#Pager(androidx.compose.ui.Modifier,androidx.compose.foundation.pager.PagerState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.gestures.Orientation,androidx.compose.foundation.gestures.TargetedFlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,kotlin.Int,androidx.compose.ui.unit.Dp,androidx.compose.foundation.pager.PageSize,androidx.compose.ui.input.nestedscroll.NestedScrollConnection,kotlin.Function1,androidx.compose.ui.Alignment.Horizontal,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.snapping.SnapPosition,androidx.compose.foundation.gestures.BringIntoViewSpec,kotlin.Function2)` in pixels. |
| `pageSpacing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The spacing used between pages in pixels. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An updated target page where to settle. Note that this value needs to be between 0 and the total count of pages in this pager. If an invalid value is passed, the pager will coerce within the valid values. |