// Initialize the carousel functionshowDefault() { for (let i = 0; i < imgCount; i++) { slides[i].style.left = i * 100 + `%`; slides_position[i] = i * 100; } }
functionshowDefault_left() { for (let i = 0; i < imgCount; i++) { slides[i].style.left = slides_position[i] + `%`; } }
functionskipSlide(targetSlide, dist) { slides_position.forEach((x, i, positions) => { positions[i] = x - dist; slides[i].style.left = `${positions[i]}%`; });
}
const rightSlideBtn = document.querySelector('.right-slide-btn'); var currentIndex = 0; rightSlideBtn.addEventListener('click', function () { let dist = 100; if (currentIndex < (imgCount - 1)) { currentIndex += 1; skipSlide(currentIndex, dist); } else { currentIndex = 0; showDefault(); } });