Tiago Nunes
07/10/2021, 11:30 PMval lazyListState = rememberLazyListState()
Here lazyListState
only has the properties firstVisibleItemScrollOffset
and firstVisibleItemIndex
.
The firstVisibleItemScrollOffset
resets to 0 after each item scroll.
I know I can do firstVisibleItemScrollOffset + firstVisibleItemIndex ª itemHeight
, but sometimes getting the itemHeight
is tricky or impossibledimsuz
07/11/2021, 12:13 AM.nestedScroll(connection)
modifier on lazy list parent and provide it with connection which will be able to "watch" the list scroll deltas.Tiago Nunes
07/11/2021, 10:38 AMTiago Nunes
07/11/2021, 11:15 AMdimsuz
07/11/2021, 12:32 PMfirstVisibleItemScrollOffset
, you should be able to find those discussions.Tiago Nunes
07/11/2021, 12:48 PMobject : NestedScrollConnection {
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
val delta = available.y
scroll.value -= delta
return Offset.Zero
}
override fun onPostScroll(
consumed: Offset,
available: Offset,
source: NestedScrollSource
): Offset {
val delta = available.y
scroll.value += delta
return Offset.Zero
}
It works, but it’s probably not very efficient, since it’s changing the scroll value a lot