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

ScrollerPosition

@Stable class ScrollerPosition
kotlin.Any
   ↳ androidx.ui.foundation.ScrollerPosition

This is the state of a VerticalScroller and HorizontalScroller that allows the developer to change the scroll position by calling methods on this object.

Summary

Public constructors
<init>(flingConfig: FlingConfig, initial: Float = 0f, isReversed: Boolean = false, animationClock: AnimationClockObservable)

This is the state of a VerticalScroller and HorizontalScroller that allows the developer to change the scroll position by calling methods on this object.

Public methods
Unit
scrollBy(value: Float)

Instantly jump by some amount of pixels

Unit
scrollTo(value: Float)

Instantly jump to position in pixels

Unit
smoothScrollBy(value: Float, onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> })

Smooth scroll by some amount of pixels

Unit
smoothScrollTo(value: Float, onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> })

Smooth scroll to position in pixels

Companion functions
Saver<ScrollerPosition, *>
Saver(flingConfig: FlingConfig, isReversed: Boolean, animationClock: AnimationClockObservable)

The default Saver implementation for ScrollerPosition.

Properties
Float

maxPosition this scroller that consume this ScrollerPosition can reach in pixels, or Float.POSITIVE_INFINITY if still unknown

Float

current scroller position value in pixels

Public constructors

<init>

ScrollerPosition(
    flingConfig: FlingConfig,
    initial: Float = 0f,
    isReversed: Boolean = false,
    animationClock: AnimationClockObservable)

This is the state of a VerticalScroller and HorizontalScroller that allows the developer to change the scroll position by calling methods on this object.

Parameters
flingConfig: FlingConfig configuration that specifies fling logic when scrolling ends with velocity
initial: Float = 0f initial scroller position in pixels to start with
isReversed: Boolean = false whether position will be reversed, e.g. 0 will mean bottom for VerticalScroller and end for HorizontalScroller
animationClock: AnimationClockObservable clock observable to run animation on. Consider querying AnimationClockAmbient to get current composition value

Public methods

scrollBy

fun scrollBy(value: Float): Unit

Instantly jump by some amount of pixels

Parameters
value: Float delta in pixels to jump by, total value will be coerced to 0..maxPosition

scrollTo

fun scrollTo(value: Float): Unit

Instantly jump to position in pixels

Parameters
value: Float target value in pixels to jump to, value will be coerced to 0..maxPosition

smoothScrollBy

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

Smooth scroll by some amount of pixels

Parameters
value: Float delta in pixels to scroll by, total value will be coerced to 0..maxPosition

smoothScrollTo

fun smoothScrollTo(
    value: Float,
    onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> }
): Unit

Smooth scroll to position in pixels

Parameters
value: Float target value in pixels to smooth scroll to, value will be coerced to 0..maxPosition

Properties

maxPosition

var maxPosition: Float

maxPosition this scroller that consume this ScrollerPosition can reach in pixels, or Float.POSITIVE_INFINITY if still unknown

value

var value: Float

current scroller position value in pixels

Companion functions

Saver

@Composable fun Saver(
    flingConfig: FlingConfig,
    isReversed: Boolean,
    animationClock: AnimationClockObservable
): Saver<ScrollerPosition, *>

The default Saver implementation for ScrollerPosition.