Status Update
Comments
ma...@google.com <ma...@google.com> #2
We could add an API to make the weighted distance customizable, aosp/3271691 has more info.
an...@google.com <an...@google.com> #3
Matvei, wdyt, could this information be collected via nested scroll maybe instead?
da...@google.com <da...@google.com> #4
Oh I don't mean the absolute total or long running dy/dx, just from the last scroll, i.e similar to the RecyclerView API.
That is, every time the list comes to rest, dy/dx resets to zero; it is only valid for a single scroll event (scroll start to finger up).
If this is still infeasible, would a LazyListState.asFlow()
api be feasible to cut down on the boilerplate of a snapshot flow?
Ultimately what is is important is being able to infer scroll direction, up/down, or left/right. I needed it when implementing a paging method to fetch more, either before or after my current scroll position. Other use cases include, showing a floating action button when the list is scrolled down, and hiding it when it is scrolled back up.
ma...@google.com <ma...@google.com> #5
re nested scroll:
It can be done via nested scroll mechanism by observing the deltas coming from the child. I don't think it'a the right abstraction though, but it might work short-medium term.
just from the last scroll
Overall I think this request makes sense, but I'm still struggling to come up with the good API for that, as when we're talking past tense - it gets complicated as in compose we don't want to deal with the past or future, only the current state. Your suggestion with Flow makes sense to me, but it should be on the Scrollable interface to be generic for all scroll-like containers I presume.
Stay tuned on this feature request.
Description
At the moment it is not easy to tell the direction the LazyList was scrolled.
It is currently only possible by:
The above is not bullet proof either as listState.firstVisibleItemScrollOffset when going between sections with sticky headers first increases monotonically, and then resets itself to 0.
Currently, to be able to fully infer scroll direction, the following is needed: