Skip to content

Commit

Permalink
[Bottom Sheet] Prevents nested scroll from occurring in a scroll sess…
Browse files Browse the repository at this point in the history
…ion when the bottom sheet is already being resized.

Previously, the bottom sheet could be fixed at any height while resizing it by triggering a fling in the opposite direction.

PiperOrigin-RevId: 628170687
  • Loading branch information
Material Design Team authored and leticiarossi committed Apr 26, 2024
1 parent 373008a commit a7a234b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,10 @@ public void onNestedPreScroll(
int currentTop = child.getTop();
int newTop = currentTop - dy;
if (dy > 0) { // Upward swipe
if (!draggableOnNestedScroll && target == scrollingChild && target.canScrollVertically(1)) {
if (!nestedScrolled
&& !draggableOnNestedScroll
&& target == scrollingChild
&& target.canScrollVertically(1)) {
// Prevent dragging if draggableOnNestedScroll=false and we can scroll the scrolling child.
draggableOnNestedScrollLastDragIgnored = true;
return;
Expand All @@ -769,7 +772,7 @@ public void onNestedPreScroll(
}
} else if (dy < 0) { // Downward swipe
boolean canScrollUp = target.canScrollVertically(-1);
if (!draggableOnNestedScroll && target == scrollingChild && canScrollUp) {
if (!nestedScrolled && !draggableOnNestedScroll && target == scrollingChild && canScrollUp) {
// Prevent dragging if draggableOnNestedScroll=false and we can scroll the scrolling child.
draggableOnNestedScrollLastDragIgnored = true;
return;
Expand Down

0 comments on commit a7a234b

Please sign in to comment.