From e84387dc1e857c07af390b960ea395e9355573ec Mon Sep 17 00:00:00 2001 From: Alex Kolpa Date: Wed, 24 Feb 2016 18:05:51 +0100 Subject: [PATCH] Fix horizontal fling The horizontal flinging was broken because the 'canScrollHorizontally' used the left and right direction incorrectly. This combined with the inverted check in 'clampViewPositionHorizontal' caused the scrolling to work, but flinging to fail. --- .../java/com/liuguangqiang/swipeback/SwipeBackLayout.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/liuguangqiang/swipeback/SwipeBackLayout.java b/library/src/main/java/com/liuguangqiang/swipeback/SwipeBackLayout.java index ea344c5..866a2f7 100644 --- a/library/src/main/java/com/liuguangqiang/swipeback/SwipeBackLayout.java +++ b/library/src/main/java/com/liuguangqiang/swipeback/SwipeBackLayout.java @@ -274,11 +274,11 @@ public boolean canChildScrollDown() { } private boolean canChildScrollRight() { - return ViewCompat.canScrollHorizontally(scrollChild, -1); + return ViewCompat.canScrollHorizontally(scrollChild, 1); } private boolean canChildScrollLeft() { - return ViewCompat.canScrollHorizontally(scrollChild, 1); + return ViewCompat.canScrollHorizontally(scrollChild, -1); } private void finish() { @@ -327,11 +327,11 @@ public int clampViewPositionHorizontal(View child, int left, int dx) { int result = 0; - if (dragEdge == DragEdge.LEFT && !canChildScrollRight() && left > 0) { + if (dragEdge == DragEdge.LEFT && !canChildScrollLeft() && left > 0) { final int leftBound = getPaddingLeft(); final int rightBound = horizontalDragRange; result = Math.min(Math.max(left, leftBound), rightBound); - } else if (dragEdge == DragEdge.RIGHT && !canChildScrollLeft() && left < 0) { + } else if (dragEdge == DragEdge.RIGHT && !canChildScrollRight() && left < 0) { final int leftBound = -horizontalDragRange; final int rightBound = getPaddingLeft(); result = Math.min(Math.max(left, leftBound), rightBound);