RotaryScrollableDefaults

object RotaryScrollableDefaults


Defaults for rotaryScrollable modifier

Summary

Constants

const Float

High snap sensitivity.

const Float

Default snap sensitivity: The standard setting, intended for general use when the user is performing typical UI navigation.

Public functions

RotaryScrollableBehavior
@Composable
behavior(
    scrollableState: ScrollableState,
    flingBehavior: FlingBehavior?,
    hapticFeedbackEnabled: Boolean
)

Implementation of RotaryScrollableBehavior to define scrolling behaviour with or without fling - used with the rotaryScrollable modifier when snapping is not required.

RotaryScrollableBehavior
@Composable
snapBehavior(
    pagerState: PagerState,
    snapOffset: Dp,
    hapticFeedbackEnabled: Boolean,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float
)

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap for HorizontalPager and VerticalPager.

RotaryScrollableBehavior
@Composable
snapBehavior(
    scrollableState: ScalingLazyListState,
    snapOffset: Dp,
    hapticFeedbackEnabled: Boolean,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float
)

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap for ScalingLazyColumn - used with the rotaryScrollable modifier when snapping is required.

RotaryScrollableBehavior
@Composable
snapBehavior(
    scrollableState: TransformingLazyColumnState,
    snapOffset: Dp,
    hapticFeedbackEnabled: Boolean,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float
)

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap for TransformingLazyColumn - used with the rotaryScrollable modifier when snapping is required.

RotaryScrollableBehavior
@Composable
snapBehavior(
    scrollableState: ScrollableState,
    layoutInfoProvider: RotarySnapLayoutInfoProvider,
    snapOffset: Dp,
    hapticFeedbackEnabled: Boolean,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float
)

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap - used with the rotaryScrollable modifier when snapping is required.

Constants

HighSnapSensitivity

Added in 1.6.0-alpha08
const val HighSnapSensitivity = 0.8f: Float

High snap sensitivity. Recommended for contexts where even a light or minimal gesture should trigger movement, such as navigating a long list (e.g. at least 10 items) where quick scrolling is desired.

SnapSensitivity

Added in 1.6.0-alpha08
const val SnapSensitivity = 0.4f: Float

Default snap sensitivity: The standard setting, intended for general use when the user is performing typical UI navigation.

Public functions

behavior

Added in 1.4.0
@Composable
fun behavior(
    scrollableState: ScrollableState,
    flingBehavior: FlingBehavior? = ScrollableDefaults.flingBehavior(),
    hapticFeedbackEnabled: Boolean = true
): RotaryScrollableBehavior

Implementation of RotaryScrollableBehavior to define scrolling behaviour with or without fling - used with the rotaryScrollable modifier when snapping is not required.

If fling is not required, set flingBehavior = null. In that case, flinging will not happen and the scrollable content will stop scrolling immediately after the user stops interacting with rotary input.

Parameters
scrollableState: ScrollableState

Scrollable state which will be scrolled while receiving rotary events.

flingBehavior: FlingBehavior? = ScrollableDefaults.flingBehavior()

Optional rotary fling behavior, pass null to turn off fling if necessary.

hapticFeedbackEnabled: Boolean = true

Controls whether haptic feedback is given during rotary scrolling (true by default). It's recommended to keep the default value of true for premium scrolling experience.

snapBehavior

Added in 1.6.0-alpha08
@Composable
fun snapBehavior(
    pagerState: PagerState,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = HighSnapSensitivity
): RotaryScrollableBehavior

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap for HorizontalPager and VerticalPager.

Parameters
pagerState: PagerState

PagerState to which rotary scroll will be connected.

snapOffset: Dp = 0.dp

An optional offset to be applied when snapping the item. Defines the distance from the center of the scrollable to the center of the snapped item.

hapticFeedbackEnabled: Boolean = true

Controls whether haptic feedback is given during rotary scrolling (true by default). It's recommended to keep the default value of true for premium scrolling experience.

snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = HighSnapSensitivity

Configures the sensitivity for rotary snapping. Defaults to RotaryScrollableDefaults.HighSnapSensitivity which is suitable for Pagers with at least 10 pages. See also RotaryScrollableDefaults.SnapSensitivity for context where there are fewer pages.

snapBehavior

Added in 1.6.0-alpha08
@Composable
fun snapBehavior(
    scrollableState: ScalingLazyListState,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = SnapSensitivity
): RotaryScrollableBehavior

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap for ScalingLazyColumn - used with the rotaryScrollable modifier when snapping is required.

Parameters
scrollableState: ScalingLazyListState

ScalingLazyListState to which rotary scroll will be connected.

snapOffset: Dp = 0.dp

An optional offset to be applied when snapping the item. Defines the distance from the center of the scrollable to the center of the snapped item.

hapticFeedbackEnabled: Boolean = true

Controls whether haptic feedback is given during rotary scrolling (true by default). It's recommended to keep the default value of true for premium scrolling experience.

snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = SnapSensitivity

Configures the sensitivity for rotary snapping. Defaults to RotaryScrollableDefaults.SnapSensitivity.

snapBehavior

Added in 1.6.0-alpha08
@Composable
fun snapBehavior(
    scrollableState: TransformingLazyColumnState,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = SnapSensitivity
): RotaryScrollableBehavior

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap for TransformingLazyColumn - used with the rotaryScrollable modifier when snapping is required.

Parameters
scrollableState: TransformingLazyColumnState

TransformingLazyColumnState to which rotary scroll will be connected.

snapOffset: Dp = 0.dp

An optional offset to be applied when snapping the item. Defines the distance from the center of the scrollable to the center of the snapped item.

hapticFeedbackEnabled: Boolean = true

Controls whether haptic feedback is given during rotary scrolling (true by default). It's recommended to keep the default value of true for premium scrolling experience.

snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = SnapSensitivity

Configures the sensitivity for rotary snapping. Defaults to SnapSensitivity.

snapBehavior

Added in 1.6.0-alpha08
@Composable
fun snapBehavior(
    scrollableState: ScrollableState,
    layoutInfoProvider: RotarySnapLayoutInfoProvider,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true,
    snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = SnapSensitivity
): RotaryScrollableBehavior

Implementation of RotaryScrollableBehavior to define scrolling behaviour with snap - used with the rotaryScrollable modifier when snapping is required.

Parameters
scrollableState: ScrollableState

Scrollable state which will be scrolled while receiving rotary events.

layoutInfoProvider: RotarySnapLayoutInfoProvider

A connection between scrollable entities and rotary events.

snapOffset: Dp = 0.dp

An optional offset to be applied when snapping the item. Defines the distance from the center of the scrollable to the center of the snapped item.

hapticFeedbackEnabled: Boolean = true

Controls whether haptic feedback is given during rotary scrolling (true by default). It's recommended to keep the default value of true for premium scrolling experience.

snapSensitivity: @FloatRange(from = 0.0, to = 1.0) Float = SnapSensitivity

Configures the sensitivity for rotary snapping. Defaults to RotaryScrollableDefaults.SnapSensitivity.