resort

"https://heritageresidencypanhala.com/wp-content/uploads/2020/11/Studio-2.jpg", "https://heritageresidencypanhala.com/wp-content/uploads/2020/11/Studio-3.jpg", ]; var totalImages = images.length; var currentIndex = 0; function updateMainImage(index) { $(".main").css("background-image", 'url(' + images[index] + ')'); $(".thumb").removeClass("current").eq(index).addClass("current"); } // Set up main image $(".main").append(""); updateMainImage(0); // Set up thumbnails images.forEach((img, index) => { $(".thumb-roll").append('
'); }); $(".thumb").click(function () { currentIndex = $(this).data("index"); updateMainImage(currentIndex); }); function nextImage() { currentIndex = (currentIndex + 1) % totalImages; updateMainImage(currentIndex); } function prevImage() { currentIndex = (currentIndex - 1 + totalImages) % totalImages; updateMainImage(currentIndex); } $(".next-btn").click(nextImage); $(".prev-btn").click(prevImage); $(document).keyup(function (e) { if (e.keyCode === 39) nextImage(); if (e.keyCode === 37) prevImage(); }); // Open popup on image click $(".main").on("click", function () { var imageUrl = images[currentIndex]; $(".popup img").attr("src", imageUrl); $(".popup").fadeIn(); }); // Close popup when clicking outside image or close button $(".close-btn, .popup").click(function (e) { if (!$(e.target).is("img")) { $(".popup").fadeOut(); } }); // Ensure popup is hidden on load $(".popup").hide(); });

Write a review