Improve scroll wheel zoom
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user