Skip to content

Commit 9773ffc

Browse files
committed
slider debounce implemented for better ux.
1 parent 9ec831d commit 9773ffc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

autoimageslider/src/main/java/com/smarteist/autoimageslider/SliderView.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,18 @@ public void setSliderTransformAnimation(SliderAnimations animation) {
380380

381381
@Override
382382
public boolean onTouch(View v, MotionEvent event) {
383-
if (event.getAction() == MotionEvent.ACTION_MOVE) {
384-
mPausedSliding = true;
385-
} else if (event.getAction() == MotionEvent.ACTION_UP) {
386-
mPausedSliding = false;
383+
if (isAutoCycle()) {
384+
if (event.getAction() == MotionEvent.ACTION_MOVE) {
385+
mPausedSliding = true;
386+
} else if (event.getAction() == MotionEvent.ACTION_UP) {
387+
// resume after ~2 seconds debounce.
388+
mHandler.postDelayed(new Runnable() {
389+
@Override
390+
public void run() {
391+
mPausedSliding = false;
392+
}
393+
}, 2000);
394+
}
387395
}
388396
return false;
389397
}

0 commit comments

Comments
 (0)