Skip to content

Commit

Permalink
Prevent discarding of drag events before reset animation is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Sep 24, 2023
1 parent a48ab27 commit 20297e5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ class SwipeableActionsState internal constructor() {
val canSwipeTowardsRight = actions.left.isNotEmpty()
val canSwipeTowardsLeft = actions.right.isNotEmpty()

// Add some resistance if needed.
val isAllowed = (targetOffset > 0f && canSwipeTowardsRight) || (targetOffset < 0f && canSwipeTowardsLeft)
val isAllowed = isResettingOnRelease
|| targetOffset == 0f
|| (targetOffset > 0f && canSwipeTowardsRight)
|| (targetOffset < 0f && canSwipeTowardsLeft)
offsetState.value += if (isAllowed) delta else delta / 10
}

Expand Down

0 comments on commit 20297e5

Please sign in to comment.