NestedScrollConnection

Interface

Common
@JvmDefaultWithCompatibility
interface NestedScrollConnection

Interface to connect to the nested scroll system.

Pass this connection to the nestedScroll 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 NestedScrollDispatcher).

Functions

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

availablethe delta available to consume for pre scroll
sourcethe source of the scroll event

Returns

the amount this connection consumed
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

consumedthe amount that was consumed by all nested scroll nodes below the hierarchy
availablethe amount of delta available for this connection to consume
sourcesource of the scroll

Returns

the amount that was consumed by this connection
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

availablethe velocity which is available to pre consume and with which the child is about to fling

Returns

the amount this connection wants to consume and take from the child
suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity

Post fling event chain. Called by the child when it is finished flinging (and sending onPreScroll & onPostScroll events)

Parameters

consumedthe amount of velocity consumed by the child
availablethe amount of velocity left for a parent to fling after the child (if desired)

Returns

the amount of velocity consumed by the fling operation in this connection