Skip to content

Commit 11e30ad

Browse files
author
Jens Claes
committed
Made horizontal scrolling more intuitive
When a scroll is started, the user probably wants to finish it. This makes scrolls a lot more intuitive (requires way less work from the user's thumb), especially when noOfVisibleDays equals 1.
1 parent e4b864d commit 11e30ad

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/src/main/java/com/alamkanak/weekview/WeekView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,10 @@ public void computeScroll() {
11531153
if (Math.abs(mScroller.getFinalX() - mScroller.getCurrX()) < mWidthPerDay + mColumnGap && Math.abs(mScroller.getFinalX() - mScroller.getStartX()) != 0) {
11541154
mScroller.forceFinished(true);
11551155
float leftDays = Math.round(mCurrentOrigin.x / (mWidthPerDay + mColumnGap));
1156+
if(mScroller.getFinalX() < mScroller.getCurrX())
1157+
leftDays--;
1158+
else
1159+
leftDays++;
11561160
int nearestOrigin = (int) (mCurrentOrigin.x - leftDays * (mWidthPerDay+mColumnGap));
11571161
mStickyScroller.startScroll((int) mCurrentOrigin.x, 0, - nearestOrigin, 0);
11581162
ViewCompat.postInvalidateOnAnimation(WeekView.this);

0 commit comments

Comments
 (0)