diff --git a/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/LazyScrollbarUtilities.kt b/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/LazyScrollbarUtilities.kt index c4ce8c22d..2c1df0c66 100644 --- a/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/LazyScrollbarUtilities.kt +++ b/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/LazyScrollbarUtilities.kt @@ -116,8 +116,11 @@ internal inline fun LazyState.inter if (firstItemIndex < 0) return Float.NaN + val firstItemSize = itemSize(firstItem) + if (firstItemSize == 0) return Float.NaN + val itemOffset = offset(firstItem).toFloat() - val offsetPercentage = abs(itemOffset) / itemSize(firstItem) + val offsetPercentage = abs(itemOffset) / firstItemSize val nextItem = nextItemOnMainAxis(firstItem) ?: return firstItemIndex + offsetPercentage