From 98f8f3b2ca6fd337a3560d113b48c2622452a78f Mon Sep 17 00:00:00 2001 From: TrianguloY Date: Tue, 29 Sep 2020 05:43:44 +0200 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/13856 - Prevent overscroll in swipe to switch tabs gesture --- .../mozilla/fenix/browser/ToolbarGestureHandler.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/ToolbarGestureHandler.kt b/app/src/main/java/org/mozilla/fenix/browser/ToolbarGestureHandler.kt index 6c975a075c..63d196f59d 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/ToolbarGestureHandler.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/ToolbarGestureHandler.kt @@ -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 -> {