Skip to content

Commit 92a74c3

Browse files
authored
Merge pull request #267 from CactiChameleon9/patch-1
Zoom towards the center of the screen
2 parents ed1e6c9 + da497e2 commit 92a74c3

File tree

1 file changed

+8
-3
lines changed
  • app/src/main/kotlin/com/simplemobiletools/draw/pro/views

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import com.simplemobiletools.draw.pro.models.MyPath
2222
import com.simplemobiletools.draw.pro.models.PaintOptions
2323
import java.util.concurrent.ExecutionException
2424
import kotlin.math.abs
25-
import kotlin.math.max
26-
import kotlin.math.min
2725

2826
class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
2927
private val MIN_ERASER_WIDTH = 20f
@@ -439,10 +437,17 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
439437
mPath.reset()
440438
}
441439

440+
if (mScaleFactor * detector.scaleFactor !in 0.1f..10.0f) {
441+
return true
442+
}
443+
442444
mIgnoreTouches = true
443445
mWasScalingInGesture = true
444446
mScaleFactor *= detector.scaleFactor
445-
mScaleFactor = max(0.1f, min(mScaleFactor, 10.0f))
447+
448+
mPosX *= detector.scaleFactor
449+
mPosY *= detector.scaleFactor
450+
446451
setBrushSize(mCurrBrushSize)
447452
invalidate()
448453
return true

0 commit comments

Comments
 (0)