https://kotlinlang.org logo
#compose-web
Title
# compose-web
a

agrosner

08/19/2022, 5:30 PM
i was not discouraged when I learned that scrolling within canvas is not supported yet. So i took it upon myself to fix it (hackily): 1. define a global channel
val scrollListener = Channel<Double>()
2. Consume it in your scrollable composable:
Copy code
val scrollState = rememberLazyListState() 
  LaunchedEffect(Unit) {
        scrollListener.consumeAsFlow()
            .collect {
                scrollState.scrollBy(it.toFloat())
            }
    }
3. attach it to a window event:
Copy code
fun main() {
    window.addEventListener("wheel", { event ->
        if (event is WheelEvent) {
            event.stopPropagation()
            GlobalScope.launch {
                scrollListener.trySend(event.deltaY)
            }
        }
    })
}
then you have scrolling support
4 Views