Skip to content

Commit

Permalink
[BottomSheetBehavior] Ignore ACTION_MOVE events in BottomSheetBehavio…
Browse files Browse the repository at this point in the history
…r that weren't preceded by an ACTION_DOWN event.

PiperOrigin-RevId: 512670230
  • Loading branch information
Material Design Team authored and paulfthomas committed Feb 27, 2023
1 parent 68c844c commit d8c01c1
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -215,6 +215,8 @@ void onLayout(@NonNull View bottomSheet) {}

private static final int VIEW_INDEX_BOTTOM_SHEET = 0;

private static final int INVALID_POSITION = -1;

@VisibleForTesting
static final int VIEW_INDEX_ACCESSIBILITY_DELEGATE_VIEW = 1;

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

int activePointerId;

private int initialY;
private int initialY = INVALID_POSITION;

boolean touchingScrollingChild;

Expand Down Expand Up @@ -653,6 +655,7 @@ public boolean onInterceptTouchEvent(
&& state != STATE_DRAGGING
&& !parent.isPointInChildBounds(scroll, (int) event.getX(), (int) event.getY())
&& viewDragHelper != null
&& initialY != INVALID_POSITION
&& Math.abs(initialY - event.getY()) > viewDragHelper.getTouchSlop();
}

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

private void reset() {
activePointerId = ViewDragHelper.INVALID_POINTER;
initialY = INVALID_POSITION;
if (velocityTracker != null) {
velocityTracker.recycle();
velocityTracker = null;
Expand Down

0 comments on commit d8c01c1

Please sign in to comment.