Tiago Nunes
07/13/2021, 9:57 AMval maxTopOffset = with(LocalDensity.current) { 240.dp.toPx() }
val topOffset = remember { mutableStateOf(maxTopOffset) }
val scrollableState = ScrollableState { delta ->
val newOffset =
(topOffset.value + delta).coerceIn(0f, maxTopOffset)
val consumed = newOffset - topOffset.value
topOffset.value = newOffset
consumed
}
Surface(Modifier.fillMaxSize().scrollable(scrollableState, Orientation.Vertical).graphicsLayer { translationY = topOffset.value }) {}
This works, but the default fling behavior behaves weird. I think this is because I’m not calculating the consumeScrollDelta properly, but I can’t find any good examples for this. Any help?