1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| const slideDots = document.querySelector('.slide-dots');
for (let i = 0; i < imgCount; i++) { const dot = document.createElement('span'); dot.classList.add('slide-dot'); dot.dataset.index = i; slideDots.appendChild(dot); }
function setActiveDot(index) { const dots = document.querySelectorAll('.slide-dot'); dots.forEach(dot => dot.classList.remove('active-dot')); dots[index].classList.add('active-dot'); }
function showDefault() { for (let i = 0; i < imgCount; i++) { slides[i].style.left = i * 100 + `%`; slides_position[i] = i * 100; } setActiveDot(0); }
function showDefault_left() { for (let i = 0; i < imgCount; i++) { slides[i].style.left = slides_position[i] + `%`; } setActiveDot(currentIndex); }
function skipSlide(targetSlide, dist) { slides_position.forEach((x, i, positions) => { positions[i] = x - dist; slides[i].style.left = `${positions[i]}%`; }); setActiveDot(targetSlide); }
|