rememberSnapperFlingBehavior

fun rememberSnapperFlingBehavior(lazyListState: LazyListState, snapOffsetForItem: (layoutInfo: SnapperLayoutInfo, item: SnapperLayoutItemInfo) -> Int = SnapOffsets.Center, endContentPadding: Dp = 0.dp, decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(), springAnimationSpec: AnimationSpec<Float> = SnapperFlingBehaviorDefaults.SpringAnimationSpec, snapIndex: (SnapperLayoutInfo, startIndex: Int, targetIndex: Int) -> Int): SnapperFlingBehavior(source)

Create and remember a snapping FlingBehavior to be used with LazyListState.

This is a convenience function for using rememberLazyListSnapperLayoutInfo and rememberSnapperFlingBehavior. If you require access to the layout info, you can safely use those APIs directly.

Parameters

lazyListState

The LazyListState to update.

snapOffsetForItem

Block which returns which offset the given item should 'snap' to. See SnapOffsets for provided values.

endContentPadding

The amount of content padding on the end edge of the lazy list in dps (end/bottom depending on the scrolling direction).

decayAnimationSpec

The decay animation spec to use for decayed flings.

springAnimationSpec

The animation spec to use when snapping.

snapIndex

Block which returns the index to snap to. The block is provided with the SnapperLayoutInfo, the index where the fling started, and the index which Snapper has determined is the correct target index. Callers can override this value to any valid index for the layout. Some common use cases include limiting the fling distance, and rounding up/down to achieve snapping to groups of items.


fun rememberSnapperFlingBehavior(lazyListState: LazyListState, snapOffsetForItem: (layoutInfo: SnapperLayoutInfo, item: SnapperLayoutItemInfo) -> Int = SnapOffsets.Center, endContentPadding: Dp = 0.dp, decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(), springAnimationSpec: AnimationSpec<Float> = SnapperFlingBehaviorDefaults.SpringAnimationSpec): SnapperFlingBehavior(source)

Create and remember a snapping FlingBehavior to be used with LazyListState.

This is a convenience function for using rememberLazyListSnapperLayoutInfo and rememberSnapperFlingBehavior. If you require access to the layout info, you can safely use those APIs directly.

Parameters

lazyListState

The LazyListState to update.

snapOffsetForItem

Block which returns which offset the given item should 'snap' to. See SnapOffsets for provided values.

endContentPadding

The amount of content padding on the end edge of the lazy list in dps (end/bottom depending on the scrolling direction).

decayAnimationSpec

The decay animation spec to use for decayed flings.

springAnimationSpec

The animation spec to use when snapping.


fun rememberSnapperFlingBehavior(layoutInfo: SnapperLayoutInfo, decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(), springAnimationSpec: AnimationSpec<Float> = SnapperFlingBehaviorDefaults.SpringAnimationSpec, snapIndex: (SnapperLayoutInfo, startIndex: Int, targetIndex: Int) -> Int): SnapperFlingBehavior(source)

Create and remember a snapping FlingBehavior to be used with the given layoutInfo.

Parameters

layoutInfo

The SnapperLayoutInfo to use. For lazy layouts, you can use rememberLazyListSnapperLayoutInfo.

decayAnimationSpec

The decay animation spec to use for decayed flings.

springAnimationSpec

The animation spec to use when snapping.

snapIndex

Block which returns the index to snap to. The block is provided with the SnapperLayoutInfo, the index where the fling started, and the index which Snapper has determined is the correct target index. Callers can override this value to any valid index for the layout. Some common use cases include limiting the fling distance, and rounding up/down to achieve snapping to groups of items.


inline fun rememberSnapperFlingBehavior(layoutInfo: SnapperLayoutInfo, decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(), springAnimationSpec: AnimationSpec<Float> = SnapperFlingBehaviorDefaults.SpringAnimationSpec): SnapperFlingBehavior(source)

Create and remember a snapping FlingBehavior to be used with the given layoutInfo.

Parameters

layoutInfo

The SnapperLayoutInfo to use. For lazy layouts, you can use rememberLazyListSnapperLayoutInfo.

decayAnimationSpec

The decay animation spec to use for decayed flings.

springAnimationSpec

The animation spec to use when snapping.