This commit is contained in:
Roman Pyrih
2024-12-20 15:48:16 +01:00
parent d9fb74972a
commit a5e1095e2c
3 changed files with 620 additions and 596 deletions

View File

@@ -20,34 +20,34 @@ function enableScroll() {
//Gallery lightbox
document.addEventListener("DOMContentLoaded", () => {
// ===> DOM elements <=== //
const $imagesContainer = document.getElementById('gallery-lightbox');
const $lightbox = document.getElementById('lightbox');
// ===> Event listeners and triggers <=== //
if ($imagesContainer && $lightbox) {
// ===> Event listeners and triggers <=== //
// Show lightbox
$imagesContainer.addEventListener('click', e => {
const imageWrapper = e.target.closest('.gallery-image');
if (imageWrapper) {
const image = imageWrapper.querySelector('img');
if (image) {
$lightbox.innerHTML = '<div class="close-lightbox"></div>' + image.outerHTML;
$lightbox.classList.add('show');
// Show lightbox
$imagesContainer.addEventListener('click', e => {
const imageWrapper = e.target.closest('.gallery-image');
if (imageWrapper) {
const image = imageWrapper.querySelector('img');
if (image) {
$lightbox.innerHTML = '<div class="close-lightbox"></div>' + image.outerHTML;
$lightbox.classList.add('show');
}
}
}
});
});
// Hide Lightbox
$lightbox.addEventListener('click', (e) => {
if (!e.target.hasAttribute('src')) {
$lightbox.classList.remove('show');
}
});
// Hide Lightbox
$lightbox.addEventListener('click', (e) => {
if (!e.target.hasAttribute('src')) {
$lightbox.classList.remove('show');
}
});
// Loading...
setTimeout(() =>
$imagesContainer.classList.remove('loading')
, 1500);
});
// Loading...
setTimeout(() => {
$imagesContainer.classList.remove('loading');
}, 1500);
}
});