Hi all! Is it possible to consume the scroll delta...
# compose
i
Hi all! Is it possible to consume the scroll delta offset of a LazyRow? I think I can't just use the ScrollableController modifier.
👌 1
j
Check the LazyScrollState attribute of the Composable ;)
i
You mean the
LazyListState
? In this case, the onScroll function is internal and we don't have access to the consumed distance. Also the
firstVisibleItemScrollOffset
is the offset of the first item.
s
You can use
firstVisibleItemScrollOffset
for getting offset like this
Copy code
val collapseRange = with(AmbientDensity.current) { (TopItemHeight).toPx() }
val collapseFraction =
    (scrollState.firstVisibleItemScrollOffset / collapseRange).coerceIn(0f, 1f)
👍 1
But you have to check if Item is first one because it reset after each item scrollState.firstVisibleItemIndex > 0
👍 2
i
Yes, I made a similar solution with
firstVisibleItemScrollOffset
but I think it would be much simpler if we had access to the
onScroll
function.
j
Yep I was thinking the solution as Shakil because unfortunately there is no global scroll offset available for LazyRow or LazyColumn
1