Skip to content

Commit e84387d

Browse files
committed
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.
1 parent b92e825 commit e84387d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/src/main/java/com/liuguangqiang/swipeback/SwipeBackLayout.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ public boolean canChildScrollDown() {
274274
}
275275

276276
private boolean canChildScrollRight() {
277-
return ViewCompat.canScrollHorizontally(scrollChild, -1);
277+
return ViewCompat.canScrollHorizontally(scrollChild, 1);
278278
}
279279

280280
private boolean canChildScrollLeft() {
281-
return ViewCompat.canScrollHorizontally(scrollChild, 1);
281+
return ViewCompat.canScrollHorizontally(scrollChild, -1);
282282
}
283283

284284
private void finish() {
@@ -327,11 +327,11 @@ public int clampViewPositionHorizontal(View child, int left, int dx) {
327327

328328
int result = 0;
329329

330-
if (dragEdge == DragEdge.LEFT && !canChildScrollRight() && left > 0) {
330+
if (dragEdge == DragEdge.LEFT && !canChildScrollLeft() && left > 0) {
331331
final int leftBound = getPaddingLeft();
332332
final int rightBound = horizontalDragRange;
333333
result = Math.min(Math.max(left, leftBound), rightBound);
334-
} else if (dragEdge == DragEdge.RIGHT && !canChildScrollLeft() && left < 0) {
334+
} else if (dragEdge == DragEdge.RIGHT && !canChildScrollRight() && left < 0) {
335335
final int leftBound = -horizontalDragRange;
336336
final int rightBound = getPaddingLeft();
337337
result = Math.min(Math.max(left, leftBound), rightBound);

0 commit comments

Comments
 (0)