ListFocusSnapFlingBehaviorKt

Added in 1.0.0-alpha02

public final class ListFocusSnapFlingBehaviorKt


Summary

Public methods

static final @NonNull SnapLayoutInfoProvider

List snapping aligns the focus line with the center of the closest item.

static final @NonNull FlingBehavior

Creates and remembers a focus-aware fling behavior that aligns the focus line with the center of the element expected to gain focus at the end of the fling.

Public methods

SnapLayoutInfoProvider

public static final @NonNull SnapLayoutInfoProvider SnapLayoutInfoProvider(@NonNull ListState state)

List snapping aligns the focus line with the center of the closest item. Combined with adaptive scrolling, this ensures that users have to move the same distance when swipes between items of the similar size, resulting in predictable movement.

Parameters
@NonNull ListState state

The ListState to observe for layout and focus information.

Returns
@NonNull SnapLayoutInfoProvider

A focus-aware SnapLayoutInfoProvider instance.

rememberSnapFlingBehavior

@Composable
public static final @NonNull FlingBehavior rememberSnapFlingBehavior(@NonNull ListState state)

Creates and remembers a focus-aware fling behavior that aligns the focus line with the center of the element expected to gain focus at the end of the fling. This ensures predictable movement for users.

Parameters
@NonNull ListState state

The ListState to observe for layout and focus information.

Returns
@NonNull FlingBehavior

A FlingBehavior instance that provides focus-aware snapping.