Skip to content

Commit

Permalink
For mozilla-mobile#13856 - Prevent overscroll in swipe to switch tabs…
Browse files Browse the repository at this point in the history
… gesture
  • Loading branch information
TrianguloY committed Sep 29, 2020
1 parent 25f62f1 commit b07af9c
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,27 @@ class ToolbarGestureHandler(
when (getDestination()) {
is Destination.Tab -> {
// Restrict the range of motion for the views so you can't start a swipe in one direction
// then move your finger far enough in the other direction and make the content visually
// start sliding off screen the other way.
// then move your finger far enough or in the other direction and make the content visually
// start sliding off screen.
tabPreview.translationX = when (gestureDirection) {
GestureDirection.RIGHT_TO_LEFT -> min(
windowWidth.toFloat() + previewOffset,
tabPreview.translationX - distanceX
)
).coerceAtLeast(0f)
GestureDirection.LEFT_TO_RIGHT -> max(
-windowWidth.toFloat() - previewOffset,
tabPreview.translationX - distanceX
)
).coerceAtMost(0f)
}
contentLayout.translationX = when (gestureDirection) {
GestureDirection.RIGHT_TO_LEFT -> min(
0f,
contentLayout.translationX - distanceX
)
).coerceAtLeast(-windowWidth.toFloat() - previewOffset)
GestureDirection.LEFT_TO_RIGHT -> max(
0f,
contentLayout.translationX - distanceX
)
).coerceAtMost(windowWidth.toFloat() + previewOffset)
}
}
is Destination.None -> {
Expand Down

0 comments on commit b07af9c

Please sign in to comment.