diff --git a/static/animation.css b/static/animation.css index 3a00876..7b7c247 100644 --- a/static/animation.css +++ b/static/animation.css @@ -13,7 +13,7 @@ margin: 0; position: absolute; top: 0; - transition: top 0.5s ease-in-out; + transition: top 1s ease-in-out; } /* Style for individual items in the carousel */ diff --git a/static/scroll.js b/static/scroll.js index 3811a17..b949390 100644 --- a/static/scroll.js +++ b/static/scroll.js @@ -1,17 +1,47 @@ -const carouselList = document.getElementById('carouselList'); -const items = carouselList.getElementsByClassName('carousel-item'); -const itemHeight = items[0].offsetHeight; -const totalItems = items.length; -let currentIndex = 0; +// JavaScript for autoscrolling all carousels simultaneously +const carouselContainers = document.querySelectorAll('.carousel-container'); +const carousels = []; -function scrollCarousel() { - currentIndex++; - if (currentIndex === totalItems) { - currentIndex = 0; +carouselContainers.forEach(container => { + const carouselList = container.querySelector('.carousel-list'); + const items = carouselList.getElementsByClassName('carousel-item'); + const itemHeight = items[0].offsetHeight; + const totalItems = items.length; + let currentIndex = 0; + let isResetting = false; + + // Push each carousel object into an array + carousels.push({ + carouselList, + itemHeight, + totalItems, + currentIndex, + isResetting + }); +}); + +function scrollAllCarousels() { + carousels.forEach(carousel => { + carousel.currentIndex++; + if (carousel.currentIndex === carousel.totalItems) { + carousel.isResetting = true; + carousel.currentIndex = 0; + carousel.carouselList.style.transition = 'top 0.5s ease-in-out'; // Enable transition for smooth scrolling + carousel.carouselList.style.top = `${-carousel.itemHeight}px`; // Start scroll animation } - const displacement = -currentIndex * itemHeight; - carouselList.style.top = displacement + 'px'; + if (carousel.isResetting && carousel.currentIndex === 0) { + // If resetting and back to the top, reset the top position instantly without animation + carousel.isResetting = false; + carousel.carouselList.style.transition = 'none'; // Disable transition for instant reset + carousel.carouselList.style.top = '0px'; // Reset to the top instantly + setTimeout(() => { + carousel.carouselList.style.transition = ''; // Re-enable transition + }, 50); // Add a slight delay before re-enabling transition to ensure it takes effect + } + const displacement = -carousel.currentIndex * carousel.itemHeight; + carousel.carouselList.style.top = `${displacement}px`; + }); } -// Set interval for autoscrolling (adjust timing as needed) -const scrollInterval = setInterval(scrollCarousel, 2000); \ No newline at end of file +// Set interval for autoscrolling all carousels simultaneously +setInterval(scrollAllCarousels, 3000); diff --git a/templates/screen.html b/templates/screen.html index 585b1e3..dcc3d3c 100644 --- a/templates/screen.html +++ b/templates/screen.html @@ -4,6 +4,7 @@ +