Reprototyping of scoreboard without bootstrap carousel

This commit is contained in:
Lucas Patenaude
2024-04-03 15:59:57 -06:00
parent 227bde2178
commit 08ff912a79
6 changed files with 55 additions and 5 deletions

View File

@@ -0,0 +1,31 @@
document.addEventListener('DOMContentLoaded', function () {
const carouselInner = document.querySelector('#scoreboard-container');
const carouselItems = Array.from(carouselInner.children);
const carouselControlPrev = document.querySelector('.carousel-control-prev');
const carouselControlNext = document.querySelector('.carousel-control-next');
let currentIndex = 0;
const updateCarousel = () => {
carouselItems.forEach((item, index) => {
if (index === currentIndex) {
item.classList.add('active');
} else {
item.classList.remove('active');
}
});
};
carouselControlPrev.addEventListener('click', () => {
if (currentIndex > 0) {
currentIndex--;
updateCarousel();
}
});
carouselControlNext.addEventListener('click', () => {
if (currentIndex < carouselItems.length - 1) {
currentIndex++;
updateCarousel();
}
});
});