LazyListSnapperLayoutInfo

class LazyListSnapperLayoutInfo(lazyListState: LazyListState, snapOffsetForItem: (layoutInfo: SnapperLayoutInfo, item: SnapperLayoutItemInfo) -> Int) : SnapperLayoutInfo

A SnapperLayoutInfo which works with LazyListState. Typically this would be remembered using rememberLazyListSnapperLayoutInfo.

Parameters

lazyListState

The LazyListState to update.

snapOffsetForItem

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

Constructors

Link copied to clipboard
fun LazyListSnapperLayoutInfo(lazyListState: LazyListState, snapOffsetForItem: (layoutInfo: SnapperLayoutInfo, item: SnapperLayoutItemInfo) -> Int)

Functions

Link copied to clipboard
open override fun canScrollTowardsEnd(): Boolean

Returns true if the layout has some scroll range remaining to scroll towards the end.

Link copied to clipboard
open override fun canScrollTowardsStart(): Boolean

Returns true if the layout has some scroll range remaining to scroll towards the start.

Link copied to clipboard
open override fun determineTargetIndex(    velocity: Float,     decayAnimationSpec: DecayAnimationSpec<Float>,     maximumFlingDistance: Float): Int

Calculate the desired target which should be scrolled to for the given velocity.

Link copied to clipboard
open override fun distanceToIndexSnap(index: Int): Int

Calculate the distance in pixels needed to scroll to the given index. The value returned signifies which direction to scroll in:

Properties

Link copied to clipboard
open override val currentItem: SnapperLayoutItemInfo?

The current item which covers the desired snap point, or null if there is no item. The item returned may not yet currently be snapped into the final position.

Link copied to clipboard
open override val endScrollOffset: Int

viewportEndOffset is the last visible offset, so we need to remove any end content padding to get the end of the scroll range

Link copied to clipboard
open override val startScrollOffset: Int = 0

Lazy lists always use 0 as the start scroll offset (within content padding)

Link copied to clipboard
open override val totalItemsCount: Int

The total count of items attached to the layout.

Link copied to clipboard
open override val visibleItems: Sequence<SnapperLayoutItemInfo>

A sequence containing the currently visible items in the layout.

Sources

Link copied to clipboard