RotaryScrollableAdapter


interface RotaryScrollableAdapter


An adapter which connects scrollableState to a rotary input for snapping scroll actions.

This interface defines the essential properties and methods required for a scrollable to be controlled by rotary input and perform a snap action.

Summary

Public functions

Float

Calculates the average size of an item within the scrollable.

Int

Returns the index of the item that is closest to the center.

Float

Returns the offset of the currently centered item from its centered position.

Int

The total number of items within the scrollable in scrollableState

Public properties

ScrollableState

The scrollable state used for performing scroll actions in response to rotary events.

Public functions

averageItemSize

Added in 1.4.0-alpha07
fun averageItemSize(): Float

Calculates the average size of an item within the scrollable. This is used to estimate scrolling distances for snapping when responding to rotary input.

Returns
Float

The average item size in pixels.

currentItemIndex

Added in 1.4.0-alpha07
fun currentItemIndex(): Int

Returns the index of the item that is closest to the center.

currentItemOffset

Added in 1.4.0-alpha07
fun currentItemOffset(): Float

Returns the offset of the currently centered item from its centered position. This value can be positive or negative.

Returns
Float

The offset of the current item in pixels.

totalItemsCount

Added in 1.4.0-alpha07
fun totalItemsCount(): Int

The total number of items within the scrollable in scrollableState

Public properties

scrollableState

Added in 1.4.0-alpha07
val scrollableStateScrollableState

The scrollable state used for performing scroll actions in response to rotary events.