1401const topCoord = (window.innerHeight - zoomedImage.offsetHeight) / 2;1402let clientYpercent;1403let imageYpx;1404let clientXpercent;1405let imageXpx;14061407const naturalWidth = zoomedImage.getAttribute('data-original-svg-width') || zoomedImage.naturalWidth;1408const naturalHeight = zoomedImage.getAttribute('data-original-svg-height') || zoomedImage.naturalHeight;14091410zoomedImage.style.left = `${leftCoord}px`;1411zoomedImage.style.top = `${topCoord}px`;1412
if (window.innerWidth < naturalWidth && window.innerHeight < naturalHeight) { clientXpercent = (event.clientX * 100) / window.innerWidth; imageXpx = -(clientXpercent * (naturalWidth - window.innerWidth)) / 100; clientYpercent = (event.clientY * 100) / window.innerHeight; imageYpx = -(clientYpercent * (naturalHeight - window.innerHeight)) / 100; zoomedImage.style.left = `${imageXpx}px`; zoomedImage.style.top = `${imageYpx}px`; if (isMobile) { zoomedImage.ontouchmove = e => { imageMoveWidth(e, zoomedImage); imageMoveHeight(e, zoomedImage); }; } else { zoomedImage.onmousemove = e => { imageMoveWidth(e, zoomedImage); imageMoveHeight(e, zoomedImage); }; } } else if (window.innerWidth < naturalWidth) { clientXpercent = (event.clientX * 100) / window.innerWidth; imageXpx = -(clientXpercent * (naturalWidth - window.innerWidth)) / 100; zoomedImage.style.left = `${imageXpx}px`; if (isMobile) { zoomedImage.ontouchmove = e => { imageMoveWidth(e, zoomedImage); }; } else { zoomedImage.onmousemove = e => { imageMoveWidth(e, zoomedImage); }; } } else if (window.innerHeight < naturalHeight) { clientYpercent = (event.clientY * 100) / window.innerHeight; imageYpx = -(clientYpercent * (naturalHeight - window.innerHeight)) / 100; zoomedImage.style.top = `${imageYpx}px`; if (isMobile) { zoomedImage.ontouchmove = e => { imageMoveHeight(e, zoomedImage); }; } else { zoomedImage.onmousemove = e => { imageMoveHeight(e, zoomedImage); }; } } function imageMoveWidth(e, img) { clientXpercent = ((e.touches !== undefined ? e.touches[0].clientX : e.clientX) * 100) / window.innerWidth; imageXpx = -(clientXpercent * (img.offsetWidth - window.innerWidth)) / 100; img.style.left = `${imageXpx}px`; } function imageMoveHeight(e, img) { clientYpercent = ((e.touches !== undefined ? e.touches[0].clientY : e.clientY) * 100) / window.innerHeight; imageYpx = -(clientYpercent * (img.offsetHeight - window.innerHeight)) / 100; img.style.top = `${imageYpx}px`; }}/** * @param {HTMLElement} zoomedImage */function t_zoom_mobileZoomPositioningInit(zoomedImage) { const leftCoordinate = (window.innerWidth - zoomedImage.offsetWidth) / 2; const topCoordinate = (window.innerHeight - zoomedImage.offsetHeight) / 2; zoomedImage.style.left = `${leftCoordinate}px`; zoomedImage.style.top = `${topCoordinate}px`; const currentPosition = { x: 0, y: 0, }; let startTouchPosition = {}; let currentTranslate = {}; zoomedImage.ontouchstart = e => { startTouchPosition = t_zoom_getTouchEventXY(e); }; zoomedImage.ontouchmove = e => { const currentTouchPosition = t_zoom_getTouchEventXY(e);