File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
library/src/main/java/com/sothree/slidinguppanel Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,7 @@ public enum PanelState {
207207 */
208208 private boolean mIsTouchEnabled ;
209209
210+ private float mPrevMotionX ;
210211 private float mPrevMotionY ;
211212 private float mInitialMotionX ;
212213 private float mInitialMotionY ;
@@ -961,15 +962,24 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
961962 return super .dispatchTouchEvent (ev );
962963 }
963964
965+ final float x = ev .getX ();
964966 final float y = ev .getY ();
965967
966968 if (action == MotionEvent .ACTION_DOWN ) {
967969 mIsScrollableViewHandlingTouch = false ;
970+ mPrevMotionX = x ;
968971 mPrevMotionY = y ;
969972 } else if (action == MotionEvent .ACTION_MOVE ) {
973+ float dx = x - mPrevMotionX ;
970974 float dy = y - mPrevMotionY ;
975+ mPrevMotionX = x ;
971976 mPrevMotionY = y ;
972977
978+ if (Math .abs (dx ) > Math .abs (dy )) {
979+ // Scrolling horizontally, so ignore
980+ return super .dispatchTouchEvent (ev );
981+ }
982+
973983 // If the scroll view isn't under the touch, pass the
974984 // event along to the dragView.
975985 if (!isViewUnder (mScrollableView , (int ) mInitialMotionX , (int ) mInitialMotionY )) {
You can’t perform that action at this time.
0 commit comments