Final fix for the zoom
This commit is contained in:
parent
e0b2685b16
commit
1c0add4bb1
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user