From 91ab0400d6bb366197218552faaaa768db069fd4 Mon Sep 17 00:00:00 2001 From: Ksenia Lesko Date: Mon, 7 Apr 2025 19:45:47 -0400 Subject: [PATCH] logo carousel fix --- assets/js/main.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 526cae2..a12e442 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,23 +1,24 @@ -const collapsibleButton = document.querySelector("#hamburger-menu"); -const menuContent = document.querySelector(".menu-content"); -collapsibleButton.addEventListener("click", function () { - menuContent.classList.toggle("active"); - if (menuContent.style.display === "block") { - menuContent.style.display = "none"; - } else { - menuContent.style.display = "block"; - } -}); - document.addEventListener('DOMContentLoaded', function () { + const collapsibleButton = document.querySelector("#hamburger-menu"); + const menuContent = document.querySelector(".menu-content"); + collapsibleButton.addEventListener("click", function () { + menuContent.classList.toggle("active"); + if (menuContent.style.display === "block") { + menuContent.style.display = "none"; + } else { + menuContent.style.display = "block"; + } + }); + initializeCompaniesCarousel(); - fetch('../assets/js/carousel-items.json') - .then(response => response.json()) - .then(data => { - createCarouselItems(data); - initializeCarousel(); - }) - .catch(error => console.error('Error loading JSON:', error)); + // TODO: useful for news article carousel + // fetch('../assets/js/carousel-items.json') + // .then(response => response.json()) + // .then(data => { + // createCarouselItems(data); + // initializeCarousel(); + // }) + // .catch(error => console.error('Error loading JSON:', error)); }); function createCarouselItems(items) { @@ -68,7 +69,6 @@ function initializeCarousel() { function initializeCompaniesCarousel() { const slider = document.getElementById('logoSlider'); - // Duplicate the existing logos by appending the same HTML again: slider.innerHTML += slider.innerHTML; let offset = 0; @@ -78,7 +78,6 @@ function initializeCompaniesCarousel() { offset -= speed; slider.style.transform = `translateX(${offset}px)`; - // After half of the total (2 sets) is scrolled, reset if (Math.abs(offset) >= slider.scrollWidth / 2) { offset = 0; }