|
|
@ -7,19 +7,13 @@
|
|
|
|
* Version: 1.2
|
|
|
|
* Version: 1.2
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function zoom(factor, imgName) {
|
|
|
|
function zoom(factor, imgName) {
|
|
|
|
|
|
|
|
console.log("CALL:" + imgName);
|
|
|
|
|
|
|
|
let winW = Math.max(document.documentElement.clientWidth, window.innerWidth);
|
|
|
|
let img = document.getElementById(imgName);
|
|
|
|
let img = document.getElementById(imgName);
|
|
|
|
let magni = img.parentElement;
|
|
|
|
let magni = img.parentElement;
|
|
|
|
magni.style.backgroundImage = `url("${img.src}")`;
|
|
|
|
magni.style.backgroundImage = `url("${img.src}")`;
|
|
|
|
|
|
|
|
|
|
|
|
let offset = {x: img.width * factor, y: img.height * factor};
|
|
|
|
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;
|
|
|
|
|
|
|
|
// mobile fix (for some browsers)
|
|
|
|
|
|
|
|
if (Math.max(document.documentElement.clientWidth, window.innerWidth) < 800) {
|
|
|
|
|
|
|
|
magni.style.height = "50%";
|
|
|
|
|
|
|
|
magni.style.height = img.height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup the padding (bigger zoom canvas)
|
|
|
|
// setup the padding (bigger zoom canvas)
|
|
|
|
magni.style.padding = offset.y + "px " + offset.x + "px";
|
|
|
|
magni.style.padding = offset.y + "px " + offset.x + "px";
|
|
|
|
// adjust the margin to ged rid of the extra size gained from padding
|
|
|
|
// adjust the margin to ged rid of the extra size gained from padding
|
|
|
@ -30,11 +24,6 @@ function zoom(factor, imgName) {
|
|
|
|
img.style.opacity = 0;
|
|
|
|
img.style.opacity = 0;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// img.addEventListener("touchmove", (e) => {
|
|
|
|
|
|
|
|
// e.preventDefault();
|
|
|
|
|
|
|
|
// moveBackground(getOffsetToMiddle(e));
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img.addEventListener("mousemove", (e) => {
|
|
|
|
img.addEventListener("mousemove", (e) => {
|
|
|
|
moveBackground(getOffsetToMiddle(e));
|
|
|
|
moveBackground(getOffsetToMiddle(e));
|
|
|
|
});
|
|
|
|
});
|
|
|
|