diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index eed298bbc2e..ea49df4e1cc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -158,14 +158,16 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements mVelocityHelper.calculateVelocity(ev); int action = ev.getAction() & MotionEvent.ACTION_MASK; if (action == MotionEvent.ACTION_UP && mDragging) { + float velocityX = mVelocityHelper.getXVelocity(); + float velocityY = mVelocityHelper.getYVelocity(); ReactScrollViewHelper.emitScrollEndDragEvent( this, - mVelocityHelper.getXVelocity(), - mVelocityHelper.getYVelocity()); + velocityX, + velocityY); mDragging = false; // After the touch finishes, we may need to do some scrolling afterwards either as a result // of a fling or because we need to page align the content - handlePostTouchScrolling(); + handlePostTouchScrolling(Math.round(velocityX), Math.round(velocityY)); } return super.onTouchEvent(ev); @@ -178,7 +180,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements } else { super.fling(velocityX); } - handlePostTouchScrolling(); + handlePostTouchScrolling(velocityX, 0); } @Override @@ -270,7 +272,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements * runnable that checks if we scrolled in the last frame and if so assumes we are still scrolling. */ @TargetApi(16) - private void handlePostTouchScrolling() { + private void handlePostTouchScrolling(int velocityX, int velocityY) { // If we aren't going to do anything (send events or snap to page), we can early out. if (!mSendMomentumEvents && !mPagingEnabled && !isScrollPerfLoggingEnabled()) { return; @@ -283,7 +285,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements } if (mSendMomentumEvents) { - ReactScrollViewHelper.emitScrollMomentumBeginEvent(this); + ReactScrollViewHelper.emitScrollMomentumBeginEvent(this, velocityX, velocityY); } mActivelyScrolling = false; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index cafa7bff0e9..58afb66e335 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -279,7 +279,7 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou if (mSendMomentumEvents || isScrollPerfLoggingEnabled()) { mFlinging = true; enableFpsListener(); - ReactScrollViewHelper.emitScrollMomentumBeginEvent(this); + ReactScrollViewHelper.emitScrollMomentumBeginEvent(this, 0, velocityY); Runnable r = new Runnable() { @Override public void run() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.java index bc8151322ee..f71c2965019 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.java @@ -44,8 +44,11 @@ public class ReactScrollViewHelper { emitScrollEvent(scrollView, ScrollEventType.END_DRAG, xVelocity, yVelocity); } - public static void emitScrollMomentumBeginEvent(ViewGroup scrollView) { - emitScrollEvent(scrollView, ScrollEventType.MOMENTUM_BEGIN); + public static void emitScrollMomentumBeginEvent( + ViewGroup scrollView, + int xVelocity, + int yVelocity) { + emitScrollEvent(scrollView, ScrollEventType.MOMENTUM_BEGIN, xVelocity, yVelocity); } public static void emitScrollMomentumEndEvent(ViewGroup scrollView) {