{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

NestedScrollConnection

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

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 methods

default @NonNull Velocity
onPostFling(@NonNull Velocity consumed, @NonNull Velocity available)

Post fling event chain.

default @NonNull Offset
onPostScroll(
    @NonNull Offset consumed,
    @NonNull Offset available,
    @NonNull NestedScrollSource source
)

Post scroll event pass.

default @NonNull Velocity

Pre fling event chain.

default @NonNull Offset

Pre scroll event chain.

Public methods

onPostFling

default @NonNull Velocity onPostFling(@NonNull Velocity consumed, @NonNull Velocity available)

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

Parameters
@NonNull Velocity consumed

the amount of velocity consumed by the child

@NonNull Velocity available

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

Returns
@NonNull Velocity

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

onPostScroll

default @NonNull Offset onPostScroll(
    @NonNull Offset consumed,
    @NonNull Offset available,
    @NonNull NestedScrollSource source
)

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
@NonNull Offset consumed

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

@NonNull Offset available

the amount of delta available for this connection to consume

@NonNull NestedScrollSource source

source of the scroll

Returns
@NonNull Offset

the amount that was consumed by this connection

onPreFling

default @NonNull Velocity onPreFling(@NonNull Velocity available)

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
@NonNull Velocity available

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

Returns
@NonNull Velocity

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

onPreScroll

default @NonNull Offset onPreScroll(@NonNull Offset available, @NonNull NestedScrollSource source)

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

Parameters
@NonNull Offset available

the delta available to consume for pre scroll

@NonNull NestedScrollSource source

the source of the scroll event

Returns
@NonNull Offset

the amount this connection consumed