Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leochuan committed Jun 23, 2018
1 parent 61536e2 commit a2b95be
Showing 1 changed file with 1 addition and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,28 +334,7 @@ public void setSmoothScrollInterpolator(Interpolator smoothScrollInterpolator) {

@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
final int offsetPosition;

// fix wrong scroll direction when infinite enable
if (mInfinite) {
final int currentPosition = getCurrentPosition();
final int total = getItemCount();
final int targetPosition;
if (position < currentPosition) {
int d1 = currentPosition - position;
int d2 = total - currentPosition + position;
targetPosition = d1 < d2 ? (currentPosition - d1) : (currentPosition + d2);
} else {
int d1 = position - currentPosition;
int d2 = currentPosition + total - position;
targetPosition = d1 < d2 ? (currentPosition + d1) : (currentPosition - d2);
}

offsetPosition = getOffsetToPosition(targetPosition);
} else {
offsetPosition = getOffsetToPosition(position);
}

final int offsetPosition = getOffsetToPosition(position);

if (mOrientation == VERTICAL) {
recyclerView.smoothScrollBy(0, offsetPosition, mSmoothScrollInterpolator);
Expand Down

0 comments on commit a2b95be

Please sign in to comment.