flight-screen-info/static/scroll.js
2024-04-01 00:57:50 +02:00

17 lines
570 B
JavaScript

const carouselList = document.getElementById('carouselList');
const items = carouselList.getElementsByClassName('carousel-item');
const itemHeight = items[0].offsetHeight;
const totalItems = items.length;
let currentIndex = 0;
function scrollCarousel() {
currentIndex++;
if (currentIndex === totalItems) {
currentIndex = 0;
}
const displacement = -currentIndex * itemHeight;
carouselList.style.top = displacement + 'px';
}
// Set interval for autoscrolling (adjust timing as needed)
const scrollInterval = setInterval(scrollCarousel, 2000);