rememberSnapperFlingBehavior

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

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.

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(    layoutInfo: SnapperLayoutInfo,     decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(),     springAnimationSpec: AnimationSpec<Float> = SnapperFlingBehaviorDefaults.SpringAnimationSpec,     snapIndex: (SnapperLayoutInfo, startIndex: Int, targetIndex: Int) -> Int): SnapperFlingBehavior

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

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.

Sources

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard