# NestedScrollConnection

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/input/nestedscroll/NestedScrollModifier.kt+class:androidx.compose.ui.input.nestedscroll.NestedScrollConnection) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/All
- Cmn

  ```
  interface NestedScrollConnection
  ```
Known direct subclasses [FloatingToolbarScrollBehavior](https://developer.android.com/reference/kotlin/androidx/compose/material3/FloatingToolbarScrollBehavior)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/FloatingToolbarScrollBehavior` | A FloatingToolbarScrollBehavior defines how a floating toolbar should behave when the content under it is scrolled. |

*** ** * ** ***

Interface to connect to the nested scroll system.

Pass this connection to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/nestedScroll.modifier#(androidx.compose.ui.Modifier).nestedScroll(androidx.compose.ui.input.nestedscroll.NestedScrollConnection,androidx.compose.ui.input.nestedscroll.NestedScrollDispatcher)` modifier to participate in the nested scroll hierarchy and to receive nested scroll events when they are dispatched by the scrolling child (scrolling child - the element that actually receives scrolling events and dispatches them via `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollDispatcher`).

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollDispatcher` | to learn how to dispatch nested scroll events to become a scrolling child |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/nestedScroll.modifier#(androidx.compose.ui.Modifier).nestedScroll(androidx.compose.ui.input.nestedscroll.NestedScrollConnection,androidx.compose.ui.input.nestedscroll.NestedScrollDispatcher)` | to attach this connection to the nested scroll system |

## Summary

| ### Public functions |
|---|---|---|
| `open suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPostFling(androidx.compose.ui.unit.Velocity,androidx.compose.ui.unit.Velocity)(consumed: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity, available: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity)` Post fling event chain. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPostScroll(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.input.nestedscroll.NestedScrollSource)( consumed: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, available: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, source: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollSource )` Post scroll event pass. | Cmn |
| `open suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPreFling(androidx.compose.ui.unit.Velocity)(available: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity)` Pre fling event chain. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPreScroll(androidx.compose.ui.geometry.Offset,androidx.compose.ui.input.nestedscroll.NestedScrollSource)(available: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, source: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollSource)` Pre scroll event chain. | Cmn |

## Public functions

### onPostFling

Cmn

```
open suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity
```

Post fling event chain. Called by the child when it is finished flinging (and sending `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPreScroll(androidx.compose.ui.geometry.Offset,androidx.compose.ui.input.nestedscroll.NestedScrollSource)`\&`https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPostScroll(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.input.nestedscroll.NestedScrollSource)` events)

| Parameters |
|---|---|
| `consumed: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | the amount of velocity consumed by the child |
| `available: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | the amount of velocity left for a parent to fling after the child (if desired) |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | the amount of velocity consumed by the fling operation in this connection |

### onPostScroll

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

```
open fun onPostScroll(
    consumed: Offset,
    available: Offset,
    source: NestedScrollSource
): Offset
```

Post scroll event pass. This pass occurs when the dispatching (scrolling) descendant made their consumption and notifies ancestors with what's left for them to consume.

| Parameters |
|---|---|
| `consumed: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | the amount that was consumed by all nested scroll nodes below the hierarchy |
| `available: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | the amount of delta available for this connection to consume |
| `source: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollSource` | source of the scroll |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | the amount that was consumed by this connection |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollSource` |   |

### onPreFling

Cmn

```
open suspend fun onPreFling(available: Velocity): Velocity
```

Pre fling event chain. Called by children when they are about to perform fling to allow parents to intercept and consume part of the initial velocity

| Parameters |
|---|---|
| `available: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | the velocity which is available to pre consume and with which the child is about to fling |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Velocity` | the amount this connection wants to consume and take from the child |

### onPreScroll

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

```
open fun onPreScroll(available: Offset, source: NestedScrollSource): Offset
```

Pre scroll event chain. Called by children to allow parents to consume a portion of a drag event beforehand

| Parameters |
|---|---|
| `available: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | the delta available to consume for pre scroll |
| `source: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollSource` | the source of the scroll event |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | the amount this connection consumed |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollSource` |   |