Skip to content

Commit d8c01c1

Browse files
Material Design Teampaulfthomas
authored andcommitted
[BottomSheetBehavior] Ignore ACTION_MOVE events in BottomSheetBehavior that weren't preceded by an ACTION_DOWN event.
PiperOrigin-RevId: 512670230
1 parent 68c844c commit d8c01c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ void onLayout(@NonNull View bottomSheet) {}
215215

216216
private static final int VIEW_INDEX_BOTTOM_SHEET = 0;
217217

218+
private static final int INVALID_POSITION = -1;
219+
218220
@VisibleForTesting
219221
static final int VIEW_INDEX_ACCESSIBILITY_DELEGATE_VIEW = 1;
220222

@@ -319,7 +321,7 @@ void onLayout(@NonNull View bottomSheet) {}
319321

320322
int activePointerId;
321323

322-
private int initialY;
324+
private int initialY = INVALID_POSITION;
323325

324326
boolean touchingScrollingChild;
325327

@@ -653,6 +655,7 @@ public boolean onInterceptTouchEvent(
653655
&& state != STATE_DRAGGING
654656
&& !parent.isPointInChildBounds(scroll, (int) event.getX(), (int) event.getY())
655657
&& viewDragHelper != null
658+
&& initialY != INVALID_POSITION
656659
&& Math.abs(initialY - event.getY()) > viewDragHelper.getTouchSlop();
657660
}
658661

@@ -1460,6 +1463,7 @@ private float calculateSlideOffsetWithTop(int top) {
14601463

14611464
private void reset() {
14621465
activePointerId = ViewDragHelper.INVALID_POINTER;
1466+
initialY = INVALID_POSITION;
14631467
if (velocityTracker != null) {
14641468
velocityTracker.recycle();
14651469
velocityTracker = null;

0 commit comments

Comments
 (0)