From 1c0add4bb1cb037ee7c6bcb2d5362ecfbd97d394 Mon Sep 17 00:00:00 2001 From: "Toerd@480" Date: Wed, 23 Oct 2019 23:55:38 +0200 Subject: [PATCH] Final fix for the zoom --- inc/js/main.js | 2 ++ inc/js/zoom.js | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/inc/js/main.js b/inc/js/main.js index 90abd4b..180b440 100644 --- a/inc/js/main.js +++ b/inc/js/main.js @@ -42,6 +42,8 @@ function showOverlay(overlay, imgName) { let img = document.createElement("img"); // call my zoom function (zoom.js) img.addEventListener("load", () => {zoom(0.4, imgName)}); + // fix for the zoom factor after resize + window.addEventListener("resize", () => {zoom(0.4, imgName)}); img.src = `/inc/images/${imgName}.jpg`; img.id = imgName; img.alt = imgName; diff --git a/inc/js/zoom.js b/inc/js/zoom.js index 91a1cbe..bd78573 100644 --- a/inc/js/zoom.js +++ b/inc/js/zoom.js @@ -13,11 +13,8 @@ function zoom(factor, imgName) { let offset = {x: img.width * factor, y: img.height * factor}; // Fix for firefox, somehow width larger than content (inline-block) + magni.style.width = "100%"; magni.style.width = img.width; - window.addEventListener("resize", () => { - magni.style.width = "60%"; - magni.style.width = img.width; - }); // setup the padding (bigger zoom canvas) magni.style.padding = offset.y + "px " + offset.x + "px"; // adjust the margin to ged rid of the extra size gained from padding