-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.js
111 lines (102 loc) · 3.52 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Product
const clc = document.querySelector(".cancle");
const arr = document.querySelector(".arr-container");
const left_container = document.querySelector(".left-container");
arr.addEventListener("click", () => {
arr.classList.add("active-arr");
if (left_container.classList.contains("off")) {
left_container.classList.remove("off");
left_container.classList.add("active");
}
});
clc.addEventListener("click", () => {
arr.classList.remove("active-arr");
if (left_container.classList.contains("active")) {
left_container.classList.remove("active");
left_container.classList.add("off");
}
});
const clc1 = document.querySelector(".cancle1");
const arr1 = document.querySelector(".arr1");
const left_container1 = document.querySelector(".left1");
arr1.addEventListener("click", () => {
arr1.classList.add("active-arr");
if (left_container1.classList.contains("off")) {
left_container1.classList.remove("off");
left_container1.classList.add("active");
}
});
clc1.addEventListener("click", () => {
arr1.classList.remove("active-arr");
if (left_container1.classList.contains("active")) {
left_container1.classList.remove("active");
left_container1.classList.add("off");
}
});
const clc2 = document.querySelector(".cancle2");
const arr2 = document.querySelector(".arr2");
const left_container2 = document.querySelector(".left2");
arr2.addEventListener("click", () => {
arr2.classList.add("active-arr");
if (left_container2.classList.contains("off")) {
left_container2.classList.remove("off");
left_container2.classList.add("active");
}
});
clc2.addEventListener("click", () => {
arr2.classList.remove("active-arr");
if (left_container2.classList.contains("active")) {
left_container2.classList.remove("active");
left_container2.classList.add("off");
}
});
const clc3 = document.querySelector(".cancle3");
const arr3 = document.querySelector(".arr3");
const left_container3 = document.querySelector(".left3");
arr3.addEventListener("click", () => {
arr3.classList.add("active-arr");
if (left_container3.classList.contains("off")) {
left_container3.classList.remove("off");
left_container3.classList.add("active");
}
});
clc3.addEventListener("click", () => {
arr3.classList.remove("active-arr");
if (left_container3.classList.contains("active")) {
left_container3.classList.remove("active");
left_container3.classList.add("off");
}
});
// End Product
// Service
const prev = document.querySelector(".prev");
const next = document.querySelector(".next");
const slides = document.querySelectorAll(".slide");
let currentIndex = 0;
next.addEventListener("click", () => {
if (currentIndex == slides.length - 1) {
currentIndex = 0;
document.querySelector(".active").classList.remove("active");
slides[currentIndex].classList.add("active");
return;
}
if (currentIndex < slides.length) {
document.querySelector(".active").classList.remove("active");
currentIndex++;
slides[currentIndex].classList.add("active");
}
});
prev.addEventListener("click", () => {
if (currentIndex == 0) {
currentIndex = slides.length - 1;
document.querySelector(".active").classList.remove("active");
slides[currentIndex].classList.add("active");
return;
}
if (currentIndex < slides.length) {
document.querySelector(".active").classList.remove("active");
currentIndex--;
slides[currentIndex].classList.add("active");
}
});
// End Service