diff --git a/library/src/main/java/link/fls/swipestack/SwipeHelper.java b/library/src/main/java/link/fls/swipestack/SwipeHelper.java index 43b7b72..5a7489b 100644 --- a/library/src/main/java/link/fls/swipestack/SwipeHelper.java +++ b/library/src/main/java/link/fls/swipestack/SwipeHelper.java @@ -48,7 +48,7 @@ public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - if(!mListenForTouchEvents || !mSwipeStack.isEnabled()) { + if (!mListenForTouchEvents || !mSwipeStack.isEnabled()) { return false; } @@ -92,6 +92,12 @@ public boolean onTouch(View v, MotionEvent event) { return true; case MotionEvent.ACTION_UP: + dx = event.getX() - mDownX; + dy = event.getY() - mDownY; + if (Math.abs(dx + dy) <= SwipeStack.CLICK_DISTANCE_THRESHOLD) { + v.performClick(); + } + v.getParent().requestDisallowInterceptTouchEvent(false); mSwipeStack.onSwipeEnd(); checkViewPosition(); @@ -104,7 +110,7 @@ public boolean onTouch(View v, MotionEvent event) { } private void checkViewPosition() { - if(!mSwipeStack.isEnabled()) { + if (!mSwipeStack.isEnabled()) { resetViewPosition(); return; } diff --git a/library/src/main/java/link/fls/swipestack/SwipeStack.java b/library/src/main/java/link/fls/swipestack/SwipeStack.java index 175e28d..93c5af0 100644 --- a/library/src/main/java/link/fls/swipestack/SwipeStack.java +++ b/library/src/main/java/link/fls/swipestack/SwipeStack.java @@ -44,6 +44,7 @@ public class SwipeStack extends ViewGroup { public static final float DEFAULT_SWIPE_OPACITY = 1f; public static final float DEFAULT_SCALE_FACTOR = 1f; public static final boolean DEFAULT_DISABLE_HW_ACCELERATION = true; + public static final float CLICK_DISTANCE_THRESHOLD = 0; private static final String KEY_SUPER_STATE = "superState"; private static final String KEY_CURRENT_INDEX = "currentIndex";