Update texts and add clickable enlarged image lightbox
This commit is contained in:
@@ -80,10 +80,44 @@
|
||||
});
|
||||
slider.addEventListener("mouseleave", restart);
|
||||
|
||||
images.forEach(function (img) {
|
||||
img.classList.add("clickable");
|
||||
img.addEventListener("click", function (ev) {
|
||||
ev.stopPropagation();
|
||||
openLightbox(img.src);
|
||||
});
|
||||
});
|
||||
|
||||
show();
|
||||
restart();
|
||||
});
|
||||
|
||||
// ---- Lightbox ----
|
||||
var lightbox = document.getElementById("lightbox");
|
||||
var lightboxImg = lightbox ? lightbox.querySelector("img") : null;
|
||||
var lightboxClose = lightbox ? lightbox.querySelector(".lightbox-close") : null;
|
||||
|
||||
function openLightbox(src) {
|
||||
if (!lightbox || !lightboxImg) return;
|
||||
lightboxImg.src = src;
|
||||
lightbox.classList.add("open");
|
||||
lightbox.setAttribute("aria-hidden", "false");
|
||||
}
|
||||
function closeLightbox() {
|
||||
if (!lightbox) return;
|
||||
lightbox.classList.remove("open");
|
||||
lightbox.setAttribute("aria-hidden", "true");
|
||||
lightboxImg.src = "";
|
||||
}
|
||||
if (lightbox) {
|
||||
lightbox.addEventListener("click", function (ev) {
|
||||
if (ev.target === lightbox || ev.target === lightboxClose) closeLightbox();
|
||||
});
|
||||
document.addEventListener("keydown", function (ev) {
|
||||
if (ev.key === "Escape") closeLightbox();
|
||||
});
|
||||
}
|
||||
|
||||
// ---- Flash mesajları ----
|
||||
setTimeout(function () {
|
||||
document.querySelectorAll(".flash").forEach(function (el) {
|
||||
|
||||
Reference in New Issue
Block a user