Skip to content

Commit

Permalink
workaround to wrong fling direction for android P: facebook#21117
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima committed Oct 15, 2018
1 parent 8fd5bcc commit cc1d7b4
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ public void getClippingRect(Rect outClippingRect) {

@Override
public void fling(int velocityY) {
// Workaround.
// On Android P if a ScrollView is inverted, we will get a wrong sign for
// velocityY (see https://issuetracker.google.com/issues/112385925).
// At the same time, mOnScrollDispatchHelper tracks the correct velocity direction.
//
// Hence, we can use the absolute value from whatever the OS gives
// us and use the sign of what mOnScrollDispatchHelper has tracked.
velocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYFlingVelocity()));


if (mPagingEnabled) {
flingAndSnap(velocityY);
} else if (mScroller != null) {
Expand Down

0 comments on commit cc1d7b4

Please sign in to comment.