From 0a8a10346880b76065d2d63195bd4c0ae8a3624d Mon Sep 17 00:00:00 2001 From: MuffinMyHeart <416509194@qq.com> Date: Fri, 26 Nov 2021 15:44:44 +0800 Subject: [PATCH] Fix the PagerState.targetPage when the currentPageOffset between -0.5f and 0f,the targetPage is currentPage + 1 which is wrong, it should be currentPage - 1. --- pager/src/main/java/com/google/accompanist/pager/PagerState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pager/src/main/java/com/google/accompanist/pager/PagerState.kt b/pager/src/main/java/com/google/accompanist/pager/PagerState.kt index 63c684718..30a6f8d7a 100644 --- a/pager/src/main/java/com/google/accompanist/pager/PagerState.kt +++ b/pager/src/main/java/com/google/accompanist/pager/PagerState.kt @@ -157,7 +157,7 @@ class PagerState( // If the offset is 0f (or very close), return the current page currentPageOffset.absoluteValue < 0.001f -> currentPage // If we're offset towards the start, guess the previous page - currentPageOffset < -0.5f -> (currentPage - 1).coerceAtLeast(0) + currentPageOffset < 0f -> (currentPage - 1).coerceAtLeast(0) // If we're offset towards the end, guess the next page else -> (currentPage + 1).coerceAtMost(pageCount - 1) }