-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeck.js
More file actions
33 lines (27 loc) · 1.06 KB
/
Copy pathdeck.js
File metadata and controls
33 lines (27 loc) · 1.06 KB
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
let current = 0;
const total = 12;
function showSlide(n) {
document.querySelectorAll('.slide').forEach(s => s.classList.remove('active'));
document.getElementById(`slide-${n}`).classList.add('active');
document.getElementById('slideCounter').textContent = `${n + 1} / ${total}`;
document.getElementById('progressFill').style.width = `${((n + 1) / total) * 100}%`;
}
function nextSlide() {
if (current < total - 1) { current++; showSlide(current); }
}
function prevSlide() {
if (current > 0) { current--; showSlide(current); }
}
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowRight' || e.key === ' ') { e.preventDefault(); nextSlide(); }
if (e.key === 'ArrowLeft') { e.preventDefault(); prevSlide(); }
});
// Touch swipe
let touchStartX = 0;
document.addEventListener('touchstart', (e) => { touchStartX = e.touches[0].clientX; });
document.addEventListener('touchend', (e) => {
const diff = touchStartX - e.changedTouches[0].clientX;
if (Math.abs(diff) > 50) { diff > 0 ? nextSlide() : prevSlide(); }
});
showSlide(0);