🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

ScrollState

State of the scroll.

Source set: Common
public class ScrollState(initial: Int) : ScrollableState

State of the scroll. Allows the developer to change the scroll position or get current state by calling methods on this object. To be hosted and passed to Modifier.verticalScroll or Modifier.horizontalScroll

To create and automatically remember ScrollState with default parameters use rememberScrollState.

Learn how to control the state of Modifier.verticalScroll or Modifier.horizontalScroll:

Parameters

initial value of the scroll

Properties

value

Source set: Common
public var value: Int by mutableIntStateOf(initial)

current scroll position value in pixels

maxValue

Source set: Common
public var maxValue: Int

maximum bound for value, or Int.MAX_VALUE if still unknown

viewportSize

Source set: Common
public var viewportSize: Int by mutableIntStateOf(0)

Size of the viewport on the scrollable axis, or 0 if still unknown. Note that this value is only populated after the first measure pass.

interactionSource

Source set: Common
public val interactionSource: InteractionSource

InteractionSource that will be used to dispatch drag events when this list is being dragged. If you want to know whether the fling (or smooth scroll) is in progress, use isScrollInProgress.

isScrollInProgress

Source set: Common
override val isScrollInProgress: Boolean

canScrollForward

Source set: Common
override val canScrollForward: Boolean { value < maxValue }

    override val canScrollBackward: Boolean {

lastScrolledBackward

Source set: Common
override val lastScrolledBackward: Boolean

scrollIndicatorState

Source set: Common
override val scrollIndicatorState: ScrollIndicatorState?

Functions

scroll

Source set: Common
override suspend fun scroll(
        scrollPriority: MutatePriority,
        block: suspend ScrollScope.() -> Unit,
    ): Unit

dispatchRawDelta

Source set: Common
override fun dispatchRawDelta(delta: Float): Float

animateScrollTo

Source set: Common
public suspend fun animateScrollTo(
        value: Int,
        animationSpec: AnimationSpec<Float> = SpringSpec(),
    )

Scroll to position in pixels with animation.

Parameters

value target value in pixels to smooth scroll to, value will be coerced to 0..maxPosition
animationSpec animation curve for smooth scroll animation

scrollTo

Source set: Common
public suspend fun scrollTo(value: Int): Float

Instantly jump to the given position in pixels.

Cancels the currently running scroll, if any, and suspends until the cancellation is complete.

Parameters

value number of pixels to scroll by

Return

the amount of scroll consumed

Members

Companion

Source set: Common
public companion object

Properties

Saver

Source set: Common
public val Saver: Saver<ScrollState, *> =
            Saver(save = { it.value }, restore = { ScrollState(it) })

The default Saver implementation for ScrollState.