2024-12-31 09:51:01 +00:00
|
|
|
// Clone the logos-slide and append it
|
2024-12-30 06:22:29 +00:00
|
|
|
var copy = document.querySelector(".logos-slide").cloneNode(true);
|
|
|
|
document.querySelector(".logos").appendChild(copy);
|
2024-12-30 09:12:21 +00:00
|
|
|
|
2024-12-31 09:51:01 +00:00
|
|
|
// Initialize Swiper instance
|
|
|
|
const swiper = new Swiper(".swiper-container", {
|
|
|
|
slidesPerView: 1,
|
|
|
|
spaceBetween: 10,
|
|
|
|
pagination: {
|
|
|
|
el: ".swiper-pagination",
|
|
|
|
clickable: true,
|
|
|
|
},
|
|
|
|
navigation: {
|
|
|
|
nextEl: ".swiper-button-next",
|
|
|
|
prevEl: ".swiper-button-prev",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Get all descriptions and pagination buttons
|
2024-12-30 09:12:21 +00:00
|
|
|
const descriptions = document.querySelectorAll(".project-description");
|
|
|
|
const paginationButtons = document.querySelectorAll(".pagination-button");
|
2024-12-31 09:51:01 +00:00
|
|
|
const images = document.querySelectorAll(".swiper-slide img"); // Select all images within slides
|
2024-12-30 09:12:21 +00:00
|
|
|
|
2024-12-31 09:51:01 +00:00
|
|
|
// Function to update the displayed content based on the current slide index
|
2024-12-30 09:12:21 +00:00
|
|
|
function updateContent(index) {
|
|
|
|
// Hide all descriptions
|
|
|
|
descriptions.forEach((desc) => {
|
|
|
|
desc.classList.remove("active");
|
|
|
|
});
|
|
|
|
|
|
|
|
// Show the current description
|
|
|
|
const selectedDescription = document.getElementById(`description-${index}`);
|
|
|
|
if (selectedDescription) {
|
|
|
|
selectedDescription.classList.add("active");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update pagination active class
|
|
|
|
paginationButtons.forEach((button) => {
|
|
|
|
button.classList.remove("active");
|
|
|
|
});
|
2024-12-31 09:51:01 +00:00
|
|
|
if (paginationButtons[index]) {
|
|
|
|
paginationButtons[index].classList.add("active");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move Swiper to the corresponding slide
|
|
|
|
swiper.slideTo(index);
|
2024-12-30 09:12:21 +00:00
|
|
|
}
|
|
|
|
|
2024-12-31 09:51:01 +00:00
|
|
|
// Listen for Swiper slide change event
|
|
|
|
swiper.on("slideChange", () => {
|
|
|
|
const currentIndex = swiper.realIndex;
|
|
|
|
updateContent(currentIndex);
|
2024-12-30 09:12:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Event listeners for pagination buttons
|
|
|
|
paginationButtons.forEach((button, index) => {
|
|
|
|
button.addEventListener("click", () => {
|
2024-12-31 09:51:01 +00:00
|
|
|
updateContent(index); // Update content and slide
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Event listeners for image clicks
|
|
|
|
images.forEach((image) => {
|
|
|
|
image.addEventListener("click", (event) => {
|
|
|
|
const index = parseInt(event.target.closest(".swiper-slide").getAttribute("data-index"), 10);
|
|
|
|
updateContent(index); // Update content and slide
|
2024-12-30 09:12:21 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Initialize the content (first image and description are visible)
|
2024-12-31 09:51:01 +00:00
|
|
|
updateContent(swiper.realIndex);
|