Source:
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) { final int itemCount = layoutManager.getItemCount(); if (itemCount == 0) { return RecyclerView.NO_POSITION; } OrientationHelper orientationHelper = layoutManager.canScrollVertically() ? getVerticalHelper(layoutManager) : getHorizontalHelper(layoutManager); View mStartMostChildView = findStartView(layoutManager, orientationHelper); if (mStartMostChildView == null) { return RecyclerView.NO_POSITION; } final int centerPosition = layoutManager.getPosition(mStartMostChildView); if (centerPosition == RecyclerView.NO_POSITION) { return RecyclerView.NO_POSITION; } final boolean forwardDirection; if (layoutManager.canScrollHorizontally()) { forwardDirection = velocityX > 0; } else { forwardDirection = velocityY > 0; } boolean reverseLayout = false; if ((layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) { RecyclerView.SmoothScroller.ScrollVectorProvider vectorProvider = (RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager; PointF vectorForEnd = vectorProvider.computeScrollVectorForPosition(itemCount - 1); if (vectorForEnd != null) { reverseLayout = vectorForEnd.x < 0 || vectorForEnd.y < 0; } } if (centerPosition == 0 && forwardDirection == reverseLayout && distanceToCenter(layoutManager, mStartMostChildView, orientationHelper) == 0) { return RecyclerView.NO_POSITION; } return reverseLayout ? (forwardDirection ? centerPosition - 1 : centerPosition) : (forwardDirection ? centerPosition + 1 : centerPosition); }

Target:
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) { final int itemCount = layoutManager.getItemCount(); if (itemCount == 0) { return RecyclerView.NO_POSITION; } OrientationHelper orientationHelper; if (layoutManager.canScrollVertically()) { orientationHelper = getVerticalHelper(layoutManager); } else if (layoutManager.canScrollHorizontally()) { orientationHelper = getHorizontalHelper(layoutManager); } else { return RecyclerView.NO_POSITION; } View mStartMostChildView = findStartView(layoutManager, orientationHelper); if (mStartMostChildView == null) { return RecyclerView.NO_POSITION; } final int centerPosition = layoutManager.getPosition(mStartMostChildView); if (centerPosition == RecyclerView.NO_POSITION) { return RecyclerView.NO_POSITION; } final boolean forwardDirection; if (layoutManager.canScrollHorizontally()) { forwardDirection = velocityX > 0; } else { forwardDirection = velocityY > 0; } boolean reverseLayout = false; if ((layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) { RecyclerView.SmoothScroller.ScrollVectorProvider vectorProvider = (RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager; PointF vectorForEnd = vectorProvider.computeScrollVectorForPosition(itemCount - 1); if (vectorForEnd != null) { reverseLayout = vectorForEnd.x < 0 || vectorForEnd.y < 0; } } if (centerPosition == 0 && forwardDirection == reverseLayout && distanceToCenter(layoutManager, mStartMostChildView, orientationHelper) == 0) { return RecyclerView.NO_POSITION; } return reverseLayout ? (forwardDirection ? centerPosition - 1 : centerPosition) : (forwardDirection ? centerPosition + 1 : centerPosition); }