function fullScreenFunction(zoomDownButton, zoomUpButton, fullScreenButton, previousButton, playPauseButton, nextButton, closeButton, img) { let width = 100; zoomFunction(img, width, width); doDisablesButton(width); // zoom down zoomDownButton.addEventListener('click', () => { if (width > 100) zoomFunction(img, width -= 10, width); doDisablesButton(width); }); // zoom up zoomUpButton.addEventListener('click', () => { if (width < 300) zoomFunction(img, width += 10, width); doDisablesButton(width); }); // scroll document.querySelector(".full-screen").addEventListener('wheel', function (event) { if (event.deltaY > 0) { if (width > 100) zoomFunction(img, width -= 10, width); } else if (event.deltaY < 0) { if (width < 300) zoomFunction(img, width += 10, width) } doDisablesButton(width); }); // full screen fullScreenButton.addEventListener('click', () => { zoomFunction(img, width = 100, width); img.style.top = 0; img.style.left = 0; doDisablesButton(width); }); // zoomFunction function zoomFunction(img, w, h) { if (w >= 100 && w <= 300) { img.style.width = w + '%'; img.style.height = h + '%'; } if (w > 100) img.style.cursor = "grab" else img.style.cursor = "default"; } function doDisablesButton(w) { if(w <= 100) { zoomDownButton.disabled = true; zoomUpButton.disabled = false; // fullScreenButton.disabled = true; } else if(w >= 300) { zoomDownButton.disabled = false; zoomUpButton.disabled = true; // fullScreenButton.disabled = false; } else { zoomDownButton.disabled = false; zoomUpButton.disabled = false; // fullScreenButton.disabled = false; } } // drag'n'drop img.onmousedown = function (e) { if (width > 100) { let coords = getCoords(img); let shiftX = e.pageX - coords.left; let shiftY = e.pageY - coords.top; img.style.position = 'absolute'; let newImg = document.querySelector('.full-screen__container').appendChild(img); zoomFunction(newImg, width, width); newImg.style.objectFit = "contain"; newImg.style.cursor = "grabbing"; moveAt(e); img.style.zIndex = 15; function moveAt(e) { img.style.left = e.pageX - shiftX + 'px'; img.style.top = e.pageY - shiftY + 'px'; } document.onmousemove = function (e) { moveAt(e); }; img.onmouseup = function () { img.style.cursor = "grab"; document.onmousemove = null; img.onmouseup = null; }; } } img.ondragstart = function () { return false; }; function getCoords(elem) { let img = elem.getBoundingClientRect(); return { top: img.top + pageYOffset, left: img.left + pageXOffset }; } // previous if(previousButton) previousButton.onclick = function () { previous(); }; // play if(playPauseButton) playPauseButton.onclick = function () { if(!playing) { play(document.querySelector('#speed input:checked').value); playPauseButton.classList.remove("triangle"); playPauseButton.classList.add("pause"); } else { pause(); playPauseButton.classList.remove("pause"); playPauseButton.classList.add("triangle"); } }; // next if(nextButton) nextButton.onclick = function () { next(); }; //close closeButton.onclick = closeFunction; document.onkeyup = function (event) { if (event.code == "Escape") closeFunction(); }; function closeFunction() { document.querySelector(".full-screen").style.display = "none"; } }