-
Notifications
You must be signed in to change notification settings - Fork 0
/
carousel.js
47 lines (36 loc) · 1.25 KB
/
carousel.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
var carousel = document.getElementsByClassName("item"),
bLeft = document.getElementById("left"),
bRight = document.getElementById("right")
counter = 0;
bRight.addEventListener('click', moveRight);
bLeft.addEventListener('click', moveLeft);
function moveRight() {
console.log("right");
if (counter > -2) {
if (counter === 0) {
for (let i = 0; i <= 2; i++) {
carousel[i].className = "car-image-cont item move";
}
} else if (counter === -1) {
for (let i = 0; i <= 2; i++) {
carousel[i].className = "car-image-cont item move1";
}
}
counter--;
}
}
function moveLeft() {
console.log("left");
if (counter < 0) {
if (counter === -2 ) {
for (let i = 0; i <= 2; i++) {
carousel[i].className = "car-image-cont item move";
}
} else if (counter === -1 ) {
for (let i = 0; i <= 2; i++) {
carousel[i].className = "car-image-cont item";
}
}
counter++;
}
}