Google is committed to advancing racial equity for Black communities. See how.

ScrollCallback

interface ScrollCallback
androidx.compose.ui.gesture.ScrollCallback

Defines the callbacks associated with scrolling.

Summary

Public methods
open Unit

Override to be notified when the scroll has been cancelled.

open Float
onScroll(scrollDistance: Float)

Override to be notified when a distance has been scrolled.

open Unit
onStart(downPosition: Offset)

Override to be notified when a scroll has started.

open Unit
onStop(velocity: Float)

Override to be notified when a scroll has stopped.

Public methods

onCancel

open fun onCancel(): Unit

Override to be notified when the scroll has been cancelled.

This is called in response to a cancellation event such as the associated PointerInputFilter having been removed from the hierarchy.

Only called if the last called if the most recent call among onStart, onStop, and onCancel was onStart.

onScroll

open fun onScroll(scrollDistance: Float): Float

Override to be notified when a distance has been scrolled.

When overridden, return the amount of the scrollDistance that has been consumed.

Called immediately after onStart and for every subsequent pointer movement, as long as the movement was enough to constitute a scroll (the average movement on in the relevant orientation is not equal to 0).

Note: This may be called multiple times in a single pass and the values should be accumulated for each call.

Parameters
scrollDistance: Float The distance that has been scrolled. Reflects the average scroll distance of all pointers.

onStart

open fun onStart(downPosition: Offset): Unit

Override to be notified when a scroll has started.

This will be called as soon as the average distance of all pointers surpasses the touch slop in the relevant orientation.

Only called if the last called if the most recent call among onStart, onStop, and onCancel was onStop or onCancel.

Parameters
downPosition: Offset The pointer input position of the down event.

onStop

open fun onStop(velocity: Float): Unit

Override to be notified when a scroll has stopped.

This is called once all pointers have released the associated PointerInputFilter.

Only called if the last called if the most recent call among onStart, onStop, and onCancel was onStart.

Parameters
velocity: Float The velocity of the scroll in the relevant orientation at the point in time when all pointers have released the relevant PointerInputFilter. In pixels per second.