Skip to content

Instantly share code, notes, and snippets.

@TakuSemba
Created August 5, 2017 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakuSemba/1164e200dd234a2512394a55df22fb2b to your computer and use it in GitHub Desktop.
Save TakuSemba/1164e200dd234a2512394a55df22fb2b to your computer and use it in GitHub Desktop.
@Override
int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) {
boolean forwardDirection = layoutManager.canScrollHorizontally() ? velocityX > 0 : velocityY > 0;
return forwardDirection ? previousClosestPosition + 1 : previousClosestPosition - 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment