fictioneer/js/lightbox.min.js
Tetrakern 76c6e4a17d Disable no-scroll for lightbox
This causes layout shifts in its current version.
2023-01-24 23:57:49 +01:00

1 line
1.1 KiB
JavaScript

const fcn_lightbox=_$$$("fictioneer-lightbox"),fcn_lightboxTarget=fcn_lightbox.querySelector(".target");function fcn_showLightbox(e){let t=!1,o=null;if(fcn_lightboxTarget.innerHTML="",e.classList.add("lightbox-last-trigger"),"IMG"==e.tagName?(o=e.cloneNode(),t=!0):e.href&&(o=document.createElement("img"),o.src=e.href,t=!0),t&&o){o.removeAttribute("class"),o.removeAttribute("style"),o.removeAttribute("height"),o.removeAttribute("width"),fcn_lightboxTarget.appendChild(o),fcn_lightbox.classList.add("show");let e=fcn_lightbox.querySelector(".lightbox__close");e?.focus(),e?.blur()}}fcn_theBody.querySelectorAll("[data-lightbox]").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),fcn_showLightbox(e.currentTarget)})),e.addEventListener("keydown",(e=>{32!=e.keyCode&&13!=e.keyCode||(e.preventDefault(),fcn_showLightbox(e.currentTarget))}))})),document.querySelectorAll(".lightbox__close, .lightbox").forEach((e=>{e.addEventListener("click",(e=>{if("IMG"!=e.target.tagName){fcn_lightbox.classList.remove("show");let e=_$(".lightbox-last-trigger");e?.focus(),e?.blur(),e?.classList.remove("lightbox-last-trigger")}}))}));