-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
57 lines (46 loc) · 1.4 KB
/
script.js
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
let currentSlide = 0;
const slides = document.querySelectorAll('#slider-container .slide');
const totalSlides = slides.length;
let slideInterval;
function startSlideShow() {
slideInterval = setInterval(() => {
moveSlide((currentSlide + 1) % totalSlides);
}, 4000);
}
function stopSlideShow() {
clearInterval(slideInterval);
}
slides.forEach(slide => {
slide.addEventListener('mouseenter', stopSlideShow);
slide.addEventListener('mouseleave', startSlideShow);
});
document.getElementById('prev').addEventListener('click', () => {
moveSlide(currentSlide - 1);
});
document.getElementById('next').addEventListener('click', () => {
moveSlide(currentSlide + 1);
});
function moveSlide(nextSlide) {
if (nextSlide >= 0 && nextSlide < totalSlides) {
slides[currentSlide].style.left = "-800px";
slides[nextSlide].style.left = "0";
currentSlide = nextSlide;
}
}
startSlideShow();
function togglePlay(videoId, overlayId) {
var video = document.getElementById(videoId);
var overlay = document.getElementById(overlayId);
if (video.paused) {
video.play();
overlay.style.display = "none";
} else {
video.pause();
overlay.style.display = "block";
}
}
document.querySelectorAll('.video-container video').forEach(function(video) {
video.addEventListener('click', function(e) {
e.stopPropagation();
});
});