-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.js
34 lines (28 loc) · 981 Bytes
/
update.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
addEventListener("load", () => {
var index = 0;
const slides = document.querySelectorAll(".slides");
const classHide = "slides-hidden", count = slides.length;
nextSlide();
function nextSlide() {
// If its an image
if(isImage(slides[(index+1) % count])) {
slides[(index++) % count].classList.add(classHide);
slides[index % count].classList.remove(classHide);
setTimeout(nextSlide, 5000);
console.log("imagem");
} // If its a video
else {
console.log("video");
slides[(index++) % count].classList.add(classHide);
slides[index % count].classList.remove(classHide);
vid = document.getElementById("my-video");
vid.play();
vid.onended = function() {
setTimeout(nextSlide, 0);
};
}
}
function isImage(i) {
return i instanceof HTMLImageElement;
}
});