From 1133676b0e22359a9ae781eed0a79ac897b11078 Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Tue, 17 Sep 2024 08:42:15 -0700 Subject: [PATCH] Add pan and zoom Signed-off-by: Justin Georgi --- src/pages/detect.vue | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/pages/detect.vue b/src/pages/detect.vue index 0b8a6f5..bdbd080 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -15,7 +15,7 @@ Capture - + { + this.canvasOffset = {x: 0, y: 0} + this.canvasZoom = 1 const imCanvas = this.$refs.image_cvs imCanvas.width = imCanvas.clientWidth imCanvas.height = imCanvas.clientHeight @@ -602,6 +609,34 @@ f7.utils.nextFrame(() => { this.selectChip("redraw") }) + }, + startMove() { + this.canvasMoving = true + }, + endMove() { + this.canvasMoving = false + }, + makeMove(event) { + if (this.canvasMoving) { + this.canvasOffset.x += event.movementX + this.canvasOffset.y += event.movementY + this.selectChip("redraw") + } + }, + spinWheel(event) { + console.log(this.canvasOffset) + console.log({x: event.clientX, y: event.clientY}) + if (event.wheelDelta > 0) { + this.canvasZoom *= 1.05 + this.canvasOffset.x = (((1.05 ** -1) - 1)*event.clientX + this.canvasOffset.x)*1.05 + this.canvasOffset.y = (((1.05 ** -1) - 1)*event.clientY + this.canvasOffset.y)*1.05 + } else if (event.wheelDelta < 0) { + this.canvasZoom /= 1.05 + this.canvasOffset.x = ((.05)*event.clientX + this.canvasOffset.x)/1.05 + this.canvasOffset.y = ((.05)*event.clientY + this.canvasOffset.y)/1.05 + } + console.log(this.canvasOffset) + this.selectChip("redraw") } } }