Hi folks! Is there any easy way to calculate total...
# compose
a
Hi folks! Is there any easy way to calculate total scroll value of the list?
Copy code
object : NestedScrollConnection {
            override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
                totalScrolled -= available.y
}
if the list reaches the top and I keep scrolling up
available.y
will still be positive therefore scrolling back to the initial position will not make
totalScrolled
as 0
a
You can override
onPostScroll()
and accumulate `consumed.y`:
Copy code
override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset {
    totalScrolled -= consumed.y
    return Offset.Zero
}