VelocityTracker should not be cleared until pointer up

Fixes: 266736911

VelocityTracker was being cleared when it hit the end
of the View, but stretch overscroll can be flung.

Test: ScrollViewTest

Change-Id: Iadeca98360dc5a5462bcefbdd266bca92c0b6d5a
This commit is contained in:
George Mount
2023-04-14 10:23:00 -07:00
parent 011d00e117
commit b5f473ed01

View File

@@ -845,11 +845,7 @@ public class ScrollView extends FrameLayout {
// Calling overScrollBy will call onOverScrolled, which
// calls onScrollChanged if applicable.
if (overScrollBy(0, deltaY, 0, mScrollY, 0, range, 0, mOverscrollDistance, true)
&& !hasNestedScrollingParent()) {
// Break our velocity if we hit a scroll barrier.
mVelocityTracker.clear();
}
overScrollBy(0, deltaY, 0, mScrollY, 0, range, 0, mOverscrollDistance, true);
final int scrolledDeltaY = mScrollY - oldY;
final int unconsumedY = deltaY - scrolledDeltaY;
@@ -894,6 +890,7 @@ public class ScrollView extends FrameLayout {
mActivePointerId = INVALID_POINTER;
endDrag();
velocityTracker.clear();
}
break;
case MotionEvent.ACTION_CANCEL: