diff --git a/layouts/partials/gallery.html b/layouts/partials/gallery.html index 27a25f9..dc1fb92 100644 --- a/layouts/partials/gallery.html +++ b/layouts/partials/gallery.html @@ -3,7 +3,7 @@ diff --git a/layouts/partials/lightbox.html b/layouts/partials/lightbox.html index f99d1d5..a9037ee 100644 --- a/layouts/partials/lightbox.html +++ b/layouts/partials/lightbox.html @@ -9,10 +9,10 @@ {{ end }} - × + × - - + + {{/*
diff --git a/static/js/snap-gallery.js b/static/js/snap-gallery.js index bd5dd80..e41ab55 100644 --- a/static/js/snap-gallery.js +++ b/static/js/snap-gallery.js @@ -1,36 +1,36 @@ -// Open the Modal -function openModal(id) { +// Variables +var baseid = "snap-lightbox-"; +var imageIndex = 1; + +// Open the Lightbox +function openLightbox(id) { document.getElementById(baseid + id).style.display = "block"; } -// Close the Modal -function closeModal(id) { +// Close the Lightbox +function closeLightbox(id) { document.getElementById(baseid + id).style.display = "none"; } -var baseid = "snap-lightbox-"; -var slideIndex = 1; -showSlides(slideIndex); - - // Next/previous controls -function plusSlides(id, n) { - showSlides(id, slideIndex += n); +function moveLightboxItem(id, n) { + showLightboxItem(id, imageIndex += n); } -// Thumbnail image controls -function currentSlide(id, n) { - showSlides(id, slideIndex = n); +// Move lightbox to the specified item +function openLightboxItem(id, n) { + showLightboxItem(id, imageIndex = n); } -function showSlides(id, n) { +// Make a specific image visible, make others hidden +function showLightboxItem(id, n) { var i; var lightbox = document.getElementById(baseid + id); - var slides = lightbox.querySelectorAll(".snap-lightbox-inner"); - if (n > slides.length) { slideIndex = 1 } - if (n < 1) { slideIndex = slides.length } - for (i = 0; i < slides.length; i++) { - slides[i].style.display = "none"; + var images = lightbox.querySelectorAll(".snap-lightbox-inner"); + if (n > images.length) { imageIndex = 1 } + if (n < 1) { imageIndex = images.length } + for (i = 0; i < images.length; i++) { + images[i].style.display = "none"; } - slides[slideIndex - 1].style.display = "inline-block"; + images[imageIndex - 1].style.display = "inline-block"; }