Permalink
Browse files

Fix scroll events getting skipped on Android

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 2, 2017
1 parent 031feb6 commit 29e5deb85fa40a999e0fa46a11f71b33bae29933
@@ -27,8 +27,6 @@
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.
@@ -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);

0 comments on commit 29e5deb

Please sign in to comment.