logo carousel fix
This commit is contained in:
parent
1e42624fea
commit
91ab0400d6
|
@ -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 () {
|
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();
|
initializeCompaniesCarousel();
|
||||||
fetch('../assets/js/carousel-items.json')
|
// TODO: useful for news article carousel
|
||||||
.then(response => response.json())
|
// fetch('../assets/js/carousel-items.json')
|
||||||
.then(data => {
|
// .then(response => response.json())
|
||||||
createCarouselItems(data);
|
// .then(data => {
|
||||||
initializeCarousel();
|
// createCarouselItems(data);
|
||||||
})
|
// initializeCarousel();
|
||||||
.catch(error => console.error('Error loading JSON:', error));
|
// })
|
||||||
|
// .catch(error => console.error('Error loading JSON:', error));
|
||||||
});
|
});
|
||||||
|
|
||||||
function createCarouselItems(items) {
|
function createCarouselItems(items) {
|
||||||
|
@ -68,7 +69,6 @@ function initializeCarousel() {
|
||||||
function initializeCompaniesCarousel() {
|
function initializeCompaniesCarousel() {
|
||||||
const slider = document.getElementById('logoSlider');
|
const slider = document.getElementById('logoSlider');
|
||||||
|
|
||||||
// Duplicate the existing logos by appending the same HTML again:
|
|
||||||
slider.innerHTML += slider.innerHTML;
|
slider.innerHTML += slider.innerHTML;
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
@ -78,7 +78,6 @@ function initializeCompaniesCarousel() {
|
||||||
offset -= speed;
|
offset -= speed;
|
||||||
slider.style.transform = `translateX(${offset}px)`;
|
slider.style.transform = `translateX(${offset}px)`;
|
||||||
|
|
||||||
// After half of the total (2 sets) is scrolled, reset
|
|
||||||
if (Math.abs(offset) >= slider.scrollWidth / 2) {
|
if (Math.abs(offset) >= slider.scrollWidth / 2) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue