Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ void onLayout(@NonNull View bottomSheet) {}

private int lastNestedScrollDy;

private float lastNestedFlingVelocityY;

private boolean nestedScrolled;

private float hideFriction = HIDE_FRICTION;
Expand Down Expand Up @@ -775,6 +777,7 @@ public boolean onStartNestedScroll(
int type) {
lastNestedScrollDy = 0;
nestedScrolled = false;
lastNestedFlingVelocityY = 0;
return (axes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
}

Expand Down Expand Up @@ -884,7 +887,10 @@ public void onStopNestedScroll(
targetState = STATE_EXPANDED;
}
}
} else if (hideable && shouldHide(child, getYVelocity())) {
} else if (hideable
&& shouldHide(
child,
lastNestedFlingVelocityY != 0 ? lastNestedFlingVelocityY : getYVelocity())) {
targetState = STATE_HIDDEN;
} else if (lastNestedScrollDy == 0) {
int currentTop = child.getTop();
Expand Down Expand Up @@ -953,9 +959,15 @@ public boolean onNestedPreFling(
float velocityY) {

if (isNestedScrollingCheckEnabled() && hasScrollingChild()) {
return isViewScrollingChild(target)
&& ((state != STATE_EXPANDED && !draggableOnNestedScrollLastDragIgnored)
|| super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY));
boolean consumed =
isViewScrollingChild(target)
&& ((state != STATE_EXPANDED && !draggableOnNestedScrollLastDragIgnored)
|| super.onNestedPreFling(
coordinatorLayout, child, target, velocityX, velocityY));
if (consumed) {
lastNestedFlingVelocityY = velocityY;
}
return consumed;
} else {
return false;
}
Expand Down