From 677bc4ca0ee74677a8ba73793d04d85fe4ab55fb Mon Sep 17 00:00:00 2001 From: Ben Trengrove Date: Wed, 25 May 2022 13:57:03 +1000 Subject: [PATCH] Fix overscroll behaviour on Android 12 --- .../com/google/accompanist/swiperefresh/SwipeRefresh.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/swiperefresh/src/main/java/com/google/accompanist/swiperefresh/SwipeRefresh.kt b/swiperefresh/src/main/java/com/google/accompanist/swiperefresh/SwipeRefresh.kt index c09f0902b..6bb8e3b9f 100644 --- a/swiperefresh/src/main/java/com/google/accompanist/swiperefresh/SwipeRefresh.kt +++ b/swiperefresh/src/main/java/com/google/accompanist/swiperefresh/SwipeRefresh.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.unit.dp import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlin.math.absoluteValue +import kotlin.math.roundToInt private const val DragMultiplier = 0.5f @@ -150,7 +151,11 @@ private class SwipeRefreshNestedScrollConnection( } private fun onScroll(available: Offset): Offset { - state.isSwipeInProgress = true + if (available.y > 0) { + state.isSwipeInProgress = true + } else if (state.indicatorOffset.roundToInt() == 0) { + state.isSwipeInProgress = false + } val newOffset = (available.y * DragMultiplier + state.indicatorOffset).coerceAtLeast(0f) val dragConsumed = newOffset - state.indicatorOffset