Fix pinch to zoom
All checks were successful
Build Dev PWA / Build-PWA (push) Successful in 38s

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-09-25 20:04:59 -07:00
parent 8c2a135afb
commit 43ccf20561

View File

@@ -34,11 +34,10 @@ export default {
let newDistance = this.touchDistance(event.touches)
let midX = (event.touches.item(0).clientX + event.touches.item(1).clientX) / 2
let midY = (event.touches.item(0).clientY + event.touches.item(1).clientY) / 2
let scale = newDistance / this.touchPrevious.distance
let scaleChange = this.canvasZoom * (scale - 1)
this.canvasZoom *= scale
this.canvasOffset.x += -((midX - 16) * scaleChange) + (midX - this.touchPrevious.x)
this.canvasOffset.y += -((midY - 96) * scaleChange) + (midY - this.touchPrevious.y)
let zoomFactor = newDistance / this.touchPrevious.distance
this.canvasZoom *= zoomFactor
this.canvasOffset.x = (midX - 16) * (1 - zoomFactor) + this.canvasOffset.x * zoomFactor + (midX - this.touchPrevious.x)
this.canvasOffset.y = (midY - 96) * (1 - zoomFactor) + this.canvasOffset.y * zoomFactor + (midY - this.touchPrevious.y)
this.touchPrevious = {distance: newDistance, x: midX, y: midY}
break;
}