-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (43 loc) · 1.46 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
let point = document.querySelectorAll('.point')
let imageSlider = document.querySelectorAll('.imageSlider')
let about__list = document.querySelectorAll('.about__list')
leftBtn = document.getElementById('leftBtn')
rightBtn = document.getElementById('rightBtn')
point[0].classList.add('activeImage')
imageSlider[0].classList.add('activeImage')
about__list[0].classList.add('active')
let counter = 0;
function paintActiveElement(){
document.querySelector('.point.activeImage').classList.remove('activeImage')
document.querySelector('.imageSlider.activeImage').classList.remove('activeImage')
document.querySelector('.about__list.active').classList.remove('active')
imageSlider[counter].classList.add('activeImage')
point[counter].classList.add('activeImage')
about__list[counter].classList.add('active')
}
for(let i=0; i<point.length; i++){
point[i].addEventListener('click',()=>{
counter = i;
paintActiveElement()
})
}
for(let i=0; i<about__list.length; i++){
about__list[i].addEventListener('click',()=>{
counter = i;
paintActiveElement()
})
}
leftBtn.addEventListener('click',()=>{
counter--
if (counter <0 ){
counter = imageSlider.length-1
}
paintActiveElement()
})
rightBtn.addEventListener('click',()=>{
counter++
if (counter >= imageSlider.length ){
counter = 0
}
paintActiveElement()
})