Ngọc Nguyên Nguyễn
06/07/2022, 9:47 AMExample rough code:
var offset by remember { mutableStateOf(0f) }
val nestedScrollConnection = remember {
object : NestedScrollConnection {
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
val currentOffset = offset
offset = (offset - available.y).coerceIn(0f, 200f)
val delta = offset - currentOffset
return Offset(x = 0f, y = -delta)
}
}
}
Column {
Box(Modifier.fillMaxWidth().height((240f - offset).dp)
Box(Modifier.nestedScroll(nestedScrollConnection) {
LazyColumn(Modifier.fillMaxSize()) {
...
}
}
}