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

FlingBehavior

public interface FlingBehavior

Known direct subclasses
SnapFlingBehavior

A FlingBehavior that performs snapping of items to a given position.


Interface to specify fling behavior.

When drag has ended with velocity in scrollable, performFling is invoked to perform fling animation and update state via ScrollScope.scrollBy

Summary

Public methods

abstract float
performFling(@NonNull ScrollScope receiver, float initialVelocity)

Perform settling via fling animation with given velocity and suspend until fling has finished.

Public methods

performFling

abstract float performFling(@NonNull ScrollScope receiver, float initialVelocity)

Perform settling via fling animation with given velocity and suspend until fling has finished.

This functions is called with ScrollScope to drive the state change of the androidx.compose.foundation.gestures.ScrollableState via ScrollScope.scrollBy.

This function must return correct velocity left after it is finished flinging in order to guarantee proper nested scroll support.

Parameters
float initialVelocity

velocity available for fling in the orientation specified in androidx.compose.foundation.gestures.scrollable that invoked this method.

Returns
float

remaining velocity after fling operation has ended