Skip to content

Commit 9d79aba

Browse files
committed
feat: add infinite backward scrolling to Carousel Pager
1 parent dda7f28 commit 9d79aba

File tree

1 file changed

+3
-1
lines changed
  • components/carousel/src/main/java/com/guru/composecookbook/carousel

1 file changed

+3
-1
lines changed

components/carousel/src/main/java/com/guru/composecookbook/carousel/PagerState.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class PagerState(currentPage: Int = 0, minPage: Int = 0, maxPage: Int = 0) {
6363
suspend fun fling(velocity: Float) {
6464
if (velocity < 0 && currentPage == maxPage) {
6565
currentPage = minPage
66-
} else if (velocity > 0 && currentPage == minPage) return
66+
} else if (velocity > 0 && currentPage == minPage) {
67+
currentPage = maxPage
68+
}
6769

6870
_currentPageOffset.animateTo(currentPageOffset.roundToInt().toFloat())
6971
selectPage()

0 commit comments

Comments
 (0)