gridDragSelect
fun <Item> Modifier.gridDragSelect(items: List<Item>, state: DragSelectState<Item>, enableAutoScroll: Boolean = true, autoScrollThreshold: Float? = null, enableHaptics: Boolean = true, hapticFeedback: HapticFeedback? = null): Modifier
A Modifier that enables drag selection for a LazyGridState.
Example usage:
val items: List<Int> = (0..100).map { it }
LazyVerticalGrid(
state = dragSelectState.lazyGridState,
columns = GridCells.Adaptive(minSize = 128.dp),
verticalArrangement = Arrangement.spacedBy(3.dp),
horizontalArrangement = Arrangement.spacedBy(3.dp),
modifier = modifier.gridDragSelect(
items = items,
state = dragSelectState,
),
) {
// Build your gird
}
Content copied to clipboard
Return
A Modifier that enables drag selection for a LazyGridState.
Parameters
Item
The type of item in the grid.
items
The list of items in the grid.
state
The DragSelectState for maintaining state
enableAutoScroll
Whether to enable auto-scrolling when dragging near the edge of the grid.
autoScrollThreshold
The distance from the edge of the grid to start auto-scrolling.
enableHaptics
Whether to enable haptic feedback when dragging.
hapticFeedback
The HapticFeedback to use, defaults to GridDragSelectDefaults.hapticsFeedback.