Skip to content

Commit

Permalink
Fix scroll events getting skipped on Android
Browse files Browse the repository at this point in the history
Summary:
This code related to velocity would cause some scroll events to be skipped and caused some jitter for sticky headers. Not sure if there is a better fix but removing this does fix missing events and the velocity calculation still seems to be working.

**Test plan**
Tested that sticky headers now work properly on Android, tested that velocity calculation still seem to work.
Closes #15761

Differential Revision: D5760820

Pulled By: sahrens

fbshipit-source-id: 562b5f606bdc5452ca3d85efb5e0e3e7db224891
  • Loading branch information
janicduplessis authored and ide committed Sep 7, 2017
1 parent 031feb6 commit 29e5deb
Showing 1 changed file with 0 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public class OnScrollDispatchHelper {

private long mLastScrollEventTimeMs = -(MIN_EVENT_SEPARATION_MS + 1);

private static final float THRESHOLD = 0.1f; // Threshold for end fling

/**
* Call from a ScrollView in onScrollChanged, returns true if this onScrollChanged is legit (not a
* duplicate) and should be dispatched.
Expand All @@ -40,11 +38,6 @@ public boolean onScrollChanged(int x, int y) {
mPrevX != x ||
mPrevY != y;

// Skip the first calculation in each scroll
if (Math.abs(mXFlingVelocity) < THRESHOLD && Math.abs(mYFlingVelocity) < THRESHOLD) {
shouldDispatch = false;
}

if (eventTime - mLastScrollEventTimeMs != 0) {
mXFlingVelocity = (float) (x - mPrevX) / (eventTime - mLastScrollEventTimeMs);
mYFlingVelocity = (float) (y - mPrevY) / (eventTime - mLastScrollEventTimeMs);
Expand Down

0 comments on commit 29e5deb

Please sign in to comment.