intranet-apei/styles-scripts/index.js

24 lines
498 B
JavaScript
Raw Permalink Normal View History

2026-02-24 14:26:25 +00:00
const carousel = document.getElementById("carousel");
const slides = carousel.querySelectorAll("li");
let currentIndex = 0;
const intervalTime = 10000;
function goToSlide(index) {
if (index < 0) index = slides.length - 1;
if (index >= slides.length) index = 0;
slides[index].scrollIntoView({
behavior: "smooth",
inline: "center",
block: "nearest"
});
currentIndex = index;
}
function nextSlide() {
goToSlide(currentIndex + 1);
}
setInterval(nextSlide, intervalTime);