Improve scroll wheel zoom

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-09-24 20:59:55 -07:00
parent 04730ed0a6
commit 8950345975

View File

@@ -627,17 +627,15 @@
}
},
spinWheel(event) {
let zoomFactor
if (event.wheelDelta > 0) {
let scaleChange = this.canvasZoom * .05
this.canvasZoom *= 1.05
this.canvasOffset.x += -(event.offsetX * scaleChange)
this.canvasOffset.y += -(event.offsetY * scaleChange)
zoomFactor = 1.05
} else if (event.wheelDelta < 0) {
let scaleChange = this.canvasZoom * (1 / 1.05 - 1)
this.canvasZoom /= 1.05
this.canvasOffset.x += -(event.offsetX * scaleChange)
this.canvasOffset.y += -(event.offsetY * scaleChange)
zoomFactor = 1 / 1.05
}
this.canvasZoom *= zoomFactor
this.canvasOffset.x = event.offsetX * (1 - zoomFactor) + this.canvasOffset.x * zoomFactor
this.canvasOffset.y = event.offsetY * (1 - zoomFactor) + this.canvasOffset.y * zoomFactor
this.selectChip("redraw")
},
resetZoom() {