-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
69 lines (53 loc) · 1.59 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
57
58
59
60
61
62
63
64
65
66
67
68
69
function scrolldown() {
window.scrollTo(0, 600)
}
const ph = document.querySelectorAll(".loc");
const leftb = document.getElementById("left");
const rightb = document.getElementById("right")
var currentslide = 0;
var timer = setInterval(slideshow, 8000);
slideshow();
leftb.addEventListener("click", () => {
console.log("click is ok")
movleft()
resettimer()
})
rightb.addEventListener("click", () => {
console.log("rigth click is ok")
rightmov()
resettimer()
})
function movleft() {
if (currentslide == 0) {
currentslide = ph.length - 1;
console.log("we came back")
}
else {
currentslide--;
}
slidechng()
}
function rightmov() {
if (currentslide == ph.length - 1) {
currentslide = 0;
}
else {
currentslide++;
console.log("we are on second phto")
}
slidechng()
}
function slidechng() {
for (let i = 0; i < ph.length; i++) {
ph[i].classList.remove('visibility')
}
ph[currentslide].classList.add('visibility')
}
function slideshow() {
rightmov()
resettimer()
}
function resettimer() {
clearInterval(timer)
timer = setInterval(slideshow, 8000)
}