From 95d09d7750e736cca8a5740e152b395e7b9a261d Mon Sep 17 00:00:00 2001 From: klemek Date: Sat, 20 Dec 2025 21:19:56 +0100 Subject: [PATCH] fix: zoom not working as expected --- src/App.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index c4f0d25..39dbfbd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -136,10 +136,10 @@ function draw() { const imgRatio = image.value.height / image.value.width; const widthFirst = image.value.width < image.value.height; - const imgWidth = targetSize.value * (widthFirst ? 1 : 1 / imgRatio); - const imgHeight = targetSize.value * (widthFirst ? imgRatio : 1); - const dx = (targetSize.value - imgWidth * zoom.value) * centerX.value; - const dy = (targetSize.value - imgHeight * zoom.value) * centerY.value; + const imgWidth = targetSize.value * (widthFirst ? 1 : 1 / imgRatio) * zoom.value; + const imgHeight = targetSize.value * (widthFirst ? imgRatio : 1) * zoom.value; + const dx = (targetSize.value - imgWidth) * centerX.value; + const dy = (targetSize.value - imgHeight) * centerY.value; // TODO get only selected area ctx.drawImage(image.value, dx, dy, imgWidth, imgHeight);