List of usage examples for com.facebook.react.views.scroll ReactScrollViewHelper emitScrollMomentumBeginEvent
public static void emitScrollMomentumBeginEvent(ViewGroup scrollView, int xVelocity, int yVelocity)
From source file:com.rnnestedscrollview.ReactNestedScrollView.java
License:MIT License
/** * This handles any sort of scrolling that may occur after a touch is finished. This may be * momentum scrolling (fling) or because you have pagingEnabled on the scroll view. Because we * don't get any events from Android about this lifecycle, we do all our detection by creating a * runnable that checks if we scrolled in the last frame and if so assumes we are still scrolling. *///from www.j a v a 2 s .c o m private void handlePostTouchScrolling(int velocityX, int velocityY) { // If we aren't going to do anything (send events or snap to page), we can early exit out. if (!mSendMomentumEvents && !mPagingEnabled && !isScrollPerfLoggingEnabled()) { return; } // Check if we are already handling this which may occur if this is called by both the touch up // and a fling call if (mPostTouchRunnable != null) { return; } if (mSendMomentumEvents) { enableFpsListener(); ReactScrollViewHelper.emitScrollMomentumBeginEvent(this, velocityX, velocityY); } mActivelyScrolling = false; mPostTouchRunnable = new Runnable() { private boolean mSnappingToPage = false; @Override public void run() { if (mActivelyScrolling) { // We are still scrolling so we just post to check again a frame later mActivelyScrolling = false; ViewCompat.postOnAnimationDelayed(ReactNestedScrollView.this, this, ReactScrollViewHelper.MOMENTUM_DELAY); } else { if (mPagingEnabled && !mSnappingToPage) { // Only if we have pagingEnabled and we have not snapped to the page do we // need to continue checking for the scroll. And we cause that scroll by asking for it mSnappingToPage = true; flingAndSnap(0); ViewCompat.postOnAnimationDelayed(ReactNestedScrollView.this, this, ReactScrollViewHelper.MOMENTUM_DELAY); } else { if (mSendMomentumEvents) { ReactScrollViewHelper.emitScrollMomentumEndEvent(ReactNestedScrollView.this); } ReactNestedScrollView.this.mPostTouchRunnable = null; disableFpsListener(); } } } }; ViewCompat.postOnAnimationDelayed(ReactNestedScrollView.this, mPostTouchRunnable, ReactScrollViewHelper.MOMENTUM_DELAY); }