RotaryScrollableDefaults

object RotaryScrollableDefaults


Defaults for rotaryScrollable modifier

Summary

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
)

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

RotaryScrollableBehavior
@Composable
snapBehavior(
    scrollableState: ScalingLazyListState,
    snapOffset: Dp,
    hapticFeedbackEnabled: Boolean
)

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

RotaryScrollableBehavior
@Composable
snapBehavior(
    scrollableState: ScrollableState,
    layoutInfoProvider: RotarySnapLayoutInfoProvider,
    snapOffset: Dp,
    hapticFeedbackEnabled: Boolean
)

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

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

@Composable
fun snapBehavior(
    pagerState: PagerState,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true
): 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.

snapBehavior

@Composable
fun snapBehavior(
    scrollableState: ScalingLazyListState,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true
): 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.

snapBehavior

@Composable
fun snapBehavior(
    scrollableState: ScrollableState,
    layoutInfoProvider: RotarySnapLayoutInfoProvider,
    snapOffset: Dp = 0.dp,
    hapticFeedbackEnabled: Boolean = true
): 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.