Skip to content

Commit 9e01762

Browse files
authored
Merge pull request #269 from alek3y/master
Fix abrupt multitouch movement
2 parents 844693a + a09f71b commit 9e01762

File tree

1 file changed

+5
-1
lines changed
  • app/src/main/kotlin/com/simplemobiletools/draw/pro/views

1 file changed

+5
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/draw/pro/views/MyCanvas.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
6060
private var mIsBucketFillOn = false
6161
private var mWasMultitouch = false
6262
private var mIgnoreTouches = false
63+
private var mIgnoreMultitouchChanges = false
6364
private var mWasScalingInGesture = false
6465
private var mWasMovingCanvasInGesture = false
6566
private var mBackgroundColor = 0
@@ -160,7 +161,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
160161
actionMove(newValueX, newValueY)
161162
}
162163

163-
if (mAllowMovingZooming && mWasMultitouch) {
164+
if (mAllowMovingZooming && mWasMultitouch && !mIgnoreMultitouchChanges) {
164165
mPosX += x - mLastTouchX
165166
mPosY += y - mLastTouchY
166167
mWasMovingCanvasInGesture = true
@@ -169,6 +170,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
169170

170171
mLastTouchX = x
171172
mLastTouchY = y
173+
mIgnoreMultitouchChanges = false
172174
}
173175
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
174176
mActivePointerId = INVALID_POINTER_ID
@@ -179,12 +181,14 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
179181
MotionEvent.ACTION_POINTER_DOWN -> {
180182
if (mAllowMovingZooming) {
181183
mWasMultitouch = true
184+
mIgnoreMultitouchChanges = true
182185
mTouchSloppedBeforeMultitouch = mLastMotionEvent.isTouchSlop(pointerIndex, mStartX, mStartY)
183186
}
184187
}
185188
MotionEvent.ACTION_POINTER_UP -> {
186189
if (mAllowMovingZooming) {
187190
mIgnoreTouches = true
191+
mIgnoreMultitouchChanges = true
188192
actionUp(!mWasScalingInGesture && !mWasMovingCanvasInGesture)
189193
}
190194
}

0 commit comments

Comments
 (0)