diff --git a/public/s/js/f0ck.js b/public/s/js/f0ck.js index bb59b18..9d483d2 100644 --- a/public/s/js/f0ck.js +++ b/public/s/js/f0ck.js @@ -46,19 +46,44 @@ i.src = e.src; }); + // + const wheelEventListener = function(event) { + if (event.target.closest('.media-object')) { + if (event.deltaY < 0) { + document.getElementById('prev').click(); + } else if (event.deltaY > 0) { + document.getElementById('next').click(); + } + } + }; + + window.addEventListener('wheel', wheelEventListener); + // + + if(f0ckimage = document.querySelector("img#f0ck-image")) { const f0ckimagescroll = document.querySelector("#image-scroll"); + + let isImageExpanded = false; + console.log("entry point - image unclicked") + f0ckimage.addEventListener("click", async e => { e.preventDefault(); const img = await imgSize(f0ckimage); - if(img.width > img.height) - return; - f0ckimagescroll.hasAttribute("style") - ? f0ckimagescroll.removeAttribute("style") - : f0ckimagescroll.setAttribute("style", "overflow-y: scroll"); - f0ckimage.hasAttribute("style") - ? f0ckimage.removeAttribute("style") - : f0ckimage.setAttribute("style", "max-height: none; height: auto; width: 100%; position: absolute; left: 0; border: var(--img-border-width) solid var(--img-border-color); border-top: none; border-bottom: none;"); + console.log("img clicked"); + if (isImageExpanded) { + isImageExpanded = false; + f0ckimagescroll.removeAttribute("style"); + f0ckimage.removeAttribute("style"); + console.log("image is not expanded") + window.addEventListener('wheel', wheelEventListener); + } else { + if (img.width > img.height) return; + isImageExpanded = true; + window.removeEventListener('wheel', wheelEventListener); + f0ckimagescroll.setAttribute("style", "overflow-y: scroll"); + f0ckimage.setAttribute("style", "max-height: none; height: auto; width: 100%; position: absolute; left: 0; border: var(--img-border-width) solid var(--img-border-color); border-top: none; border-bottom: none;"); + } }); } // @@ -236,14 +261,6 @@ // // - window.addEventListener('wheel', function(event) { - if (event.target.closest('.media-object')) { - if (event.deltaY < 0) { - document.getElementById('prev').click(); - } else if (event.deltaY > 0) { - document.getElementById('next').click(); - } - } - }); + // })();