/
index.js
executable file
·42 lines (26 loc) · 981 Bytes
/
index.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
// home page JS
// class Carousel{
// constructor(element){
// this.carouselElement = element
// this.imageNumber = this.carouselElement.dataset.img
// this.index = 0
// let timing = setInterval(this.startShow, 1000);
// }
// startShow() {
// this.carouselElement[this.index].className = 'image-noshow'
// this.index = (this.index+1)%this.carouselElement.length
// this.carouselElement[this.index].className = 'image-show'
// }
// }
// let allImages = document.querySelectorAll('.carousel .slide')
// allImages.forEach(images => {
// return new Carousel(images)
// })
let allImages = document.querySelectorAll('.carousel .slide')
let theIndex = 0
let slideTiming = setInterval(slideShow, 6000)
function slideShow(){
allImages[theIndex].className = 'slide image-noshow'
theIndex = (theIndex+1)%allImages.length
allImages[theIndex].classList = 'slide image-show'
}