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

ScrollFieldState

A state object that can be hoisted to observe and control the scrolling behavior of a ScrollField.

Source set: Common
public class ScrollFieldState(internal val pagerState: PagerState, public val itemCount: Int)

A state object that can be hoisted to observe and control the scrolling behavior of a ScrollField.

In most cases, this state should be created via rememberScrollFieldState.

Parameters

pagerState the underlying PagerState used to handle the scroll logic.
itemCount the total number of unique items available in the scroll field.

Properties

selectedOption

Source set: Common
public var selectedOption: Int

The index of the currently selected option.

This value is always clamped between 0 and itemCount - 1. When the internal pager is scrolled, this value updates to reflect the item closest to the snap position.

Setting this value will instantly scroll to the specified option.

targetOption

Source set: Common
public val targetOption: Int

The option the pager will settle on once any in-progress scroll finishes. Equal to selectedOption when the pager is at rest.

isScrollInProgress

Source set: Common
public val isScrollInProgress: Boolean

Whether this ScrollField is currently scrolling, either by user gesture or by animation.

Functions

scrollToOption

Source set: Common
public suspend fun scrollToOption(option: Int)

Instantly scrolls to the specified option.

Parameters

option the index of the item to scroll to.

animateScrollToOption

Source set: Common
public suspend fun animateScrollToOption(option: Int)

Animates the scroll to the specified option.

Parameters

option the index of the item to animate to.