Skip to content

Commit

Permalink
优化细节
Browse files Browse the repository at this point in the history
  • Loading branch information
jenly1314 committed May 24, 2024
1 parent 06a158c commit 1e961bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ internal class UltraSwipeRefreshNestedScrollConnection(

private fun onScroll(available: Offset): Offset {
if (available.y != 0f) {
if (available.y < 0f && !loadMoreEnabled) {

if (state.indicatorOffset <= 0f && available.y < 0f && !loadMoreEnabled) {
return Offset.Zero
}
if (available.y > 0f && !refreshEnabled) {
if (state.indicatorOffset >= 0f && available.y > 0f && !refreshEnabled) {
return Offset.Zero
}

state.isSwipeInProgress = true
val dragConsumed = available.y * dragMultiplier
coroutineScope.launch {
state.dispatchScrollDelta(dragConsumed)
}
return available
return available.copy(x = 0f)
}
return Offset.Zero
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class UltraSwipeRefreshState(isRefreshing: Boolean, isLoading: Boolean) {
} else if (indicatorOffset < 0f) {
indicatorOffset.plus(delta).coerceIn(footerMinOffset, 0f)
} else {
indicatorOffset.plus(delta)
indicatorOffset.plus(delta).coerceIn(footerMinOffset, headerMaxOffset)
}
)
if(!isFinishing) {
Expand Down

0 comments on commit 1e961bf

Please sign in to comment.