I don't think it's very feasible to calculate it based on what he's given. The offset for the first visible item wraps when the offset reaches the item’s height, so you’d have to track a multiplier somehow, and it all gets very messy and complicated. Here's what worked for me:
.graphicsLayer {
lazyListState
.layoutInfo
.visibleItemsInfo
.firstOrNull()
?.offset
?.let { offset ->
alpha = 1.0f + (offset / totalSpannedDistance)
}
}
The offset obtained is in whole number integer pixels, by the way. You’ll need the denominator in your division to be in pixels, preferably a float.