Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Rey committed Feb 28, 2024
1 parent b9aa132 commit 57c0801
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/_includes/gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,24 @@
let currentSlideIndex = 0;
let slideSrcArray = []; // Array to store image source URLs

function preloadImages() {
slideSrcArray.forEach((src) => {
const img = new Image();
img.src = src;
});
}

document.addEventListener('DOMContentLoaded', function() {
preloadImages(); // Preload images when the DOM is ready
});

galleryImages.forEach((image, index) => {
image.addEventListener('click', () => {
showModal();
modalImg.src = image.dataset.srcfull;
currentSlideIndex = index;
});
slideSrcArray.push(image.src); // Store src values in the array
slideSrcArray.push(image.dataset.srcfull); // Store src values in the array
});

modal.addEventListener('click', (e) => {
Expand Down Expand Up @@ -93,6 +104,7 @@
document.body.style.overflow = 'auto'; // Restore the scrollbar
modalPrev.classList.remove('hidden');
modalNext.classList.remove('hidden');
modalImg.src = "";
}

function plusSlides(n) {
Expand Down

0 comments on commit 57c0801

Please sign in to comment.