ScrollFieldState
-
Cmn
class ScrollFieldState
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.
Summary
Public constructors |
|
|---|---|
ScrollFieldState(pagerState: PagerState, itemCount: Int) |
Cmn
|
Public functions |
||
|---|---|---|
suspend Unit |
animateScrollToOption(option: Int)Animates the scroll to the specified |
Cmn
|
suspend Unit |
scrollToOption(option: Int)Instantly scrolls to the specified |
Cmn
|
Public properties |
||
|---|---|---|
Boolean |
Whether this |
Cmn
|
Int |
the total number of unique items available in the scroll field. |
Cmn
|
Int |
The index of the currently selected option. |
Cmn
|
Public constructors
ScrollFieldState
ScrollFieldState(pagerState: PagerState, itemCount: Int)
| Parameters | |
|---|---|
pagerState: PagerState |
the underlying |
itemCount: Int |
the total number of unique items available in the scroll field. |
Public functions
animateScrollToOption
suspend fun animateScrollToOption(option: Int): Unit
Animates the scroll to the specified option.
| Parameters | |
|---|---|
option: Int |
the index of the item to animate to. |
| See also | |
|---|---|
scrollToOption |
for an instant scroll. |
scrollToOption
suspend fun scrollToOption(option: Int): Unit
Instantly scrolls to the specified option.
| Parameters | |
|---|---|
option: Int |
the index of the item to scroll to. |
| See also | |
|---|---|
animateScrollToOption |
for a smooth transition. |
Public properties
isScrollInProgress
val isScrollInProgress: Boolean
Whether this ScrollField is currently scrolling, either by user gesture or by animation.
selectedOption
val 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.