fixed a glitch with gestures being calculated wrong in some cases

This commit is contained in:
tibbi 2021-09-24 23:14:48 +02:00
parent 4a1598a2c9
commit f3a16ccc03
1 changed files with 8 additions and 13 deletions

View File

@ -288,20 +288,15 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
return true
}
var newValueX = x
var newValueY = y
val scaledWidth = width / mScaleFactor
val touchPercentageX = x / width
val compensationX = (scaledWidth / 2) * (1 - mScaleFactor)
val newValueX = scaledWidth * touchPercentageX - compensationX - (mPosX / mScaleFactor)
if (mAllowMovingZooming) {
val scaledWidth = width / mScaleFactor
val touchPercentageX = x / width
val compensationX = (scaledWidth / 2) * (1 - mScaleFactor)
newValueX = scaledWidth * touchPercentageX - compensationX - (mPosX / mScaleFactor)
val scaledHeight = height / mScaleFactor
val touchPercentageY = y / height
val compensationY = (scaledHeight / 2) * (1 - mScaleFactor)
newValueY = scaledHeight * touchPercentageY - compensationY - (mPosY / mScaleFactor)
}
val scaledHeight = height / mScaleFactor
val touchPercentageY = y / height
val compensationY = (scaledHeight / 2) * (1 - mScaleFactor)
val newValueY = scaledHeight * touchPercentageY - compensationY - (mPosY / mScaleFactor)
when (action) {
MotionEvent.ACTION_DOWN -> {