NestedScrollConnection

Known direct subclasses
FloatingAppBarScrollBehavior

A FloatingAppBarScrollBehavior defines how a floating app bar should behave when the content under it is scrolled.


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).

See also
NestedScrollDispatcher

to learn how to dispatch nested scroll events to become a scrolling child

nestedScroll

to attach this connection to the nested scroll system

Summary

Public functions

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

Post fling event chain.

Cmn
open Offset
onPostScroll(
    consumed: Offset,
    available: Offset,
    source: NestedScrollSource
)

Post scroll event pass.

Cmn
open suspend Velocity
onPreFling(available: Velocity)

Pre fling event chain.

Cmn
open Offset
onPreScroll(available: Offset, source: NestedScrollSource)

Pre scroll event chain.

Cmn

Public functions

onPostFling

open 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
consumed: Velocity

the amount of velocity consumed by the child

available: Velocity

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

Returns
Velocity

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

onPostScroll

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: Offset

the amount that was consumed by all nested scroll nodes below the hierarchy

available: Offset

the amount of delta available for this connection to consume

source: NestedScrollSource

source of the scroll

Returns
Offset

the amount that was consumed by this connection

onPreFling

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: Velocity

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

Returns
Velocity

the amount this connection wants to consume and take from the child

onPreScroll

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: Offset

the delta available to consume for pre scroll

source: NestedScrollSource

the source of the scroll event

Returns
Offset

the amount this connection consumed