mirror of
				https://github.com/SimpleMobileTools/Simple-Draw.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	Merge pull request #269 from alek3y/master
Fix abrupt multitouch movement
This commit is contained in:
		| @@ -60,6 +60,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { | ||||
|     private var mIsBucketFillOn = false | ||||
|     private var mWasMultitouch = false | ||||
|     private var mIgnoreTouches = false | ||||
|     private var mIgnoreMultitouchChanges = false | ||||
|     private var mWasScalingInGesture = false | ||||
|     private var mWasMovingCanvasInGesture = false | ||||
|     private var mBackgroundColor = 0 | ||||
| @@ -160,7 +161,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { | ||||
|                     actionMove(newValueX, newValueY) | ||||
|                 } | ||||
|  | ||||
|                 if (mAllowMovingZooming && mWasMultitouch) { | ||||
|                 if (mAllowMovingZooming && mWasMultitouch && !mIgnoreMultitouchChanges) { | ||||
|                     mPosX += x - mLastTouchX | ||||
|                     mPosY += y - mLastTouchY | ||||
|                     mWasMovingCanvasInGesture = true | ||||
| @@ -169,6 +170,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { | ||||
|  | ||||
|                 mLastTouchX = x | ||||
|                 mLastTouchY = y | ||||
|                 mIgnoreMultitouchChanges = false | ||||
|             } | ||||
|             MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { | ||||
|                 mActivePointerId = INVALID_POINTER_ID | ||||
| @@ -179,12 +181,14 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { | ||||
|             MotionEvent.ACTION_POINTER_DOWN -> { | ||||
|                 if (mAllowMovingZooming) { | ||||
|                     mWasMultitouch = true | ||||
|                     mIgnoreMultitouchChanges = true | ||||
|                     mTouchSloppedBeforeMultitouch = mLastMotionEvent.isTouchSlop(pointerIndex, mStartX, mStartY) | ||||
|                 } | ||||
|             } | ||||
|             MotionEvent.ACTION_POINTER_UP -> { | ||||
|                 if (mAllowMovingZooming) { | ||||
|                     mIgnoreTouches = true | ||||
|                     mIgnoreMultitouchChanges = true | ||||
|                     actionUp(!mWasScalingInGesture && !mWasMovingCanvasInGesture) | ||||
|                 } | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user