Reputation: 698
For some reason LazyColumn
s do not scroll with a mouse click and move gesture. It only works with the mouse wheel so far. For LazyRow
s it is also not possible to scroll with the mouse wheel. It seems that lazy row is useless for Compose for desktop.
Are there any possiblities to enable a click and move gesture on LazyRow
and LazyColum
. And if not is it at least possible to enable to scroll through a LazyRow
with the mouse wheel?
I used this minimal reproducible example to test the scrolling
@Composable
@Preview
fun App() {
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
LazyRow(modifier = Modifier.fillMaxSize()) {
repeat(100) {
item {
Text("Test Test Test Test $it ")
}
}
}
}
}
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
App()
}
}
Upvotes: 9
Views: 4098
Reputation: 88072
This is the intended behavior.
All scrollable components (including LazyColumn
) work (for now) only with mouse wheel scroll events on the desktop.
The scrollable components should not respond to mouse drag/move events.
Here's a basic example of how you can add drag support to your components:
val scrollState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
LazyRow(
state = scrollState,
modifier = Modifier
.draggable(
orientation = Orientation.Horizontal,
state = rememberDraggableState { delta ->
coroutineScope.launch {
scrollState.scrollBy(-delta)
}
},
)
) {
items(100) {
Text("Test Test Test Test $it")
}
}
Upvotes: 24