I am trying to build a Compose Multiplatform App, the nested scroll is working fine on Android and iOS but on Desktop, it is not working.
val nestedScrollConnection = remember {
object : NestedScrollConnection {
override fun onPreScroll(
available: Offset,
source: NestedScrollSource
): Offset {
imageRotation.value += (available.y * 0.5).toInt()
return Offset.Zero
}
override fun onPostScroll(
consumed: Offset,
available: Offset,
source: NestedScrollSource
): Offset {
val delta = available.y
imageRotation.value += ((delta * PI / 180) * 10).toInt()
return super.onPostScroll(consumed, available, source)
}
override suspend fun onPreFling(available: Velocity): Velocity {
imageRotation.value += available.y.toInt()
return super.onPreFling(available)
}
}
}
Box(
modifier = Modifier.fillMaxSize()
) {
LazyColumn(
contentPadding = PaddingValues(64.dp),
userScrollEnabled = true,
verticalArrangement = Arrangement.Absolute.spacedBy(16.dp),
modifier = Modifier.fillMaxSize().nestedScroll(nestedScrollConnection),
state = listState
) {
StepsAndDetails(recipe, chefImage)
}
}
Currently, i am exploring
https://github.com/JetBrains/compose-multiplatform/blob/master/tutorials/Mouse_Events/README.md mouse events for this.