@@ -164,10 +164,16 @@ private enum Direction {
164
164
165
165
@ Override
166
166
public boolean onDown (MotionEvent e ) {
167
- goToNearestOrigin ();
167
+ stopScrolling ();
168
168
return true ;
169
169
}
170
170
171
+ @ Override
172
+ public boolean onSingleTapUp (MotionEvent e ){
173
+ goToNearestOrigin ();
174
+ return false ;
175
+ }
176
+
171
177
@ Override
172
178
public boolean onScroll (MotionEvent e1 , MotionEvent e2 , float distanceX , float distanceY ) {
173
179
// Check if view is zoomed.
@@ -272,6 +278,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
272
278
273
279
@ Override
274
280
public boolean onSingleTapConfirmed (MotionEvent e ) {
281
+ goToNearestOrigin ();
275
282
276
283
// If the tap was on an event then trigger the callback.
277
284
if (mEventRects != null && mEventClickListener != null ) {
@@ -371,6 +378,7 @@ top < getHeight() &&
371
378
@ Override
372
379
public void onLongPress (MotionEvent e ) {
373
380
super .onLongPress (e );
381
+ goToNearestOrigin ();
374
382
375
383
if (mEventLongPressListener != null && mEventRects != null ) {
376
384
List <EventRect > reversedEventRects = mEventRects ;
@@ -2525,6 +2533,16 @@ public boolean onTouchEvent(MotionEvent event) {
2525
2533
return val ;
2526
2534
}
2527
2535
2536
+ /**
2537
+ * A lighter function to stop the current scroll animation
2538
+ */
2539
+ private void stopScrolling (){
2540
+ //force scroller animation stop
2541
+ mScroller .forceFinished (true );
2542
+ // Reset scrolling and fling direction.
2543
+ mCurrentScrollDirection = mCurrentFlingDirection = Direction .NONE ;
2544
+ }
2545
+
2528
2546
private void goToNearestOrigin () {
2529
2547
double leftDays = mCurrentOrigin .x / (mWidthPerDay + mColumnGap );
2530
2548
0 commit comments