mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
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 https://github.com/facebook/react-native/pull/15761 Differential Revision: D5760820 Pulled By: sahrens fbshipit-source-id: 562b5f606bdc5452ca3d85efb5e0e3e7db224891
This commit is contained in:
parent
5b79ee6808
commit
e964a7f4ef
@ -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.
|
||||
@ -40,11 +38,6 @@ public class OnScrollDispatchHelper {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user