logo carousel fix

This commit is contained in:
Ksenia Lesko 2025-04-07 19:45:47 -04:00
parent 1e42624fea
commit 91ab0400d6
Signed by: xenushka
GPG Key ID: 812A8E51AD475267
1 changed files with 19 additions and 20 deletions

View File

@ -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;
}