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

ScrollableController

class ScrollableController
kotlin.Any
   ↳ androidx.compose.foundation.gestures.ScrollableController

Controller to control the scrollable modifier with. Contains necessary information about the ongoing fling and provides smooth scrolling capabilities.

Summary

Public constructors
<init>(consumeScrollDelta: (Float) -> Float, flingConfig: FlingConfig, animationClock: AnimationClockObservable)

Controller to control the scrollable modifier with.

Public methods
Unit
smoothScrollBy(value: Float, spec: AnimationSpec<Float> = SpringSpec(), onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> })

Smooth scroll by value amount of pixels

Unit

Stop any ongoing animation, smooth scrolling or fling

Properties
(Float) -> Float

callback invoked when drag/fling/smooth scrolling occurs.

FlingConfig

fling configuration to use for flinging

Boolean

whether this ScrollableController is currently animating/flinging

Public constructors

<init>

ScrollableController(
    consumeScrollDelta: (Float) -> Float,
    flingConfig: FlingConfig,
    animationClock: AnimationClockObservable)

Controller to control the scrollable modifier with. Contains necessary information about the ongoing fling and provides smooth scrolling capabilities.

Parameters
consumeScrollDelta: (Float) -> Float callback invoked when drag/fling/smooth scrolling occurs. The callback receives the delta in pixels. Callers should update their state in this lambda and return the amount of delta consumed
flingConfig: FlingConfig fling configuration to use for flinging
animationClock: AnimationClockObservable animation clock to run flinging and smooth scrolling on

Public methods

smoothScrollBy

fun smoothScrollBy(
    value: Float,
    spec: AnimationSpec<Float> = SpringSpec(),
    onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> }
): Unit

Smooth scroll by value amount of pixels

Parameters
value: Float delta to scroll by
spec: AnimationSpec<Float> = SpringSpec() AnimationSpec to be used for this smooth scrolling
onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> } lambda to be called when smooth scrolling has ended

stopAnimation

fun stopAnimation(): Unit

Stop any ongoing animation, smooth scrolling or fling

Call this to stop receiving scrollable deltas in consumeScrollDelta

Properties

consumeScrollDelta

val consumeScrollDelta: (Float) -> Float

callback invoked when drag/fling/smooth scrolling occurs. The callback receives the delta in pixels. Callers should update their state in this lambda and return the amount of delta consumed

flingConfig

val flingConfig: FlingConfig

fling configuration to use for flinging

isAnimationRunning

val isAnimationRunning: Boolean

whether this ScrollableController is currently animating/flinging