File size: 1,949 Bytes
e27e2aa
426a524
e27e2aa
 
 
 
 
 
 
 
 
 
 
426a524
e27e2aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426a524
e27e2aa
 
 
 
 
 
 
426a524
e27e2aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426a524
e27e2aa
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

document.addEventListener('DOMContentLoaded', () => {
    const presentation = document.querySelector('.presentation-container');
    const slides = document.querySelectorAll('.slide');
    const prevBtn = document.getElementById('prev-btn');
    const nextBtn = document.getElementById('next-btn');
    let currentSlide = 0;

    // Update slide position
    function updateSlide() {
        presentation.scrollTo({
            left: currentSlide * window.innerWidth,
            behavior: 'smooth'
        });
    }

    // Next slide
    nextBtn.addEventListener('click', () => {
        if (currentSlide < slides.length - 1) {
            currentSlide++;
            updateSlide();
        }
    });

    // Previous slide
    prevBtn.addEventListener('click', () => {
        if (currentSlide > 0) {
            currentSlide--;
            updateSlide();
        }
    });

    // Keyboard navigation
    document.addEventListener('keydown', (e) => {
        if (e.key === 'ArrowRight' || e.key === ' ') {
            if (currentSlide < slides.length - 1) {
                currentSlide++;
                updateSlide();
            }
        } else if (e.key === 'ArrowLeft') {
            if (currentSlide > 0) {
                currentSlide--;
                updateSlide();
            }
        }
    });

    // Touch/swipe support
    let touchStartX = 0;
    let touchEndX = 0;

    presentation.addEventListener('touchstart', (e) => {
        touchStartX = e.changedTouches[0].screenX;
    });

    presentation.addEventListener('touchend', (e) => {
        touchEndX = e.changedTouches[0].screenX;
        handleSwipe();
    });

    function handleSwipe() {
        if (touchEndX < touchStartX && currentSlide < slides.length - 1) {
            currentSlide++;
            updateSlide();
        }
        if (touchEndX > touchStartX && currentSlide > 0) {
            currentSlide--;
            updateSlide();
        }
    }
});