Gerardo Rodriguez
01/11/2023, 4:46 PMcompose web
with skiko canvas
, the LazyColumn
seems to not behave as expected with mouse wheel.
I try to scroll down with the mouse wheel but is not working. Do I need to do something else? Is this issue already identified? Thanks!agrosner
01/11/2023, 5:28 PMagrosner
01/11/2023, 5:34 PMLaunchedEffect(Unit) {
scrollListener.consumeAsFlow()
.collect {
scrollState.scrollBy(it.toFloat())
}
}
val scrollListener = Channel<Double>()
In main js kt :
window.addEventListener("wheel", { event ->
if (event is WheelEvent) {
event.stopPropagation()
GlobalScope.launch {
scrollListener.trySend(event.deltaY)
}
}
})
agrosner
01/11/2023, 5:35 PMGerardo Rodriguez
01/11/2023, 5:38 PMburnoo
01/18/2023, 10:55 PMval scope = rememberCoroutineScope()
val listState = rememberLazyListState()
// ...
LazyColumn(
state = listState,
modifier = Modifier.onPointerEvent(PointerEventType.Scroll) {
scope.launch {
listState.scrollBy((it.nativeEvent as SkikoPointerEvent).deltaY.toFloat())
}
},
userScrollEnabled = false,
content = content,
)
Working demo: https://burnoo.github.io/DemoListApp/
Doesn’t work with touch screens though, couldn’t find workaround for that.