Skip to content

Commit

Permalink
Merge pull request #1174 from google/ben/swiperefresh
Browse files Browse the repository at this point in the history
[SwipeRefresh] Fix overscroll behaviour on Android 12
  • Loading branch information
bentrengrove committed Jun 8, 2022
2 parents a0ebf63 + 677bc4c commit 6a9615a
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6a9615a

Please sign in to comment.