-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (30 loc) · 1.19 KB
/
Copy pathscript.js
File metadata and controls
35 lines (30 loc) · 1.19 KB
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
// header
const bar = document.getElementById("bar");
const nav = document.getElementById("nav");
bar.onclick = (e) => {
const icon = e.target.getAttribute("class")
if(icon == "fa-solid fa-bars"){
e.target.setAttribute("class","fa-solid fa-xmark")
}else{
e.target.setAttribute("class","fa-solid fa-bars")
}
nav.classList.toggle("showNav")
}
// carousel
const carouselContainer = document.querySelector(".carouselContainer");
const eachCarousel = document.querySelector(".eachCarousel").clientWidth;
const allEachCarousel = document.querySelectorAll(".eachCarousel");
const allIndicator = document.querySelectorAll(".indicator");
const slideCarousel = (index) => {
for(let x = 0; x<allEachCarousel.length;x++){
if(x === index){
allEachCarousel[x].classList.add("eachCarouselBorder")
allIndicator[x].classList.add("activeIndicator")
}else{
allEachCarousel[x].classList.remove("eachCarouselBorder")
allIndicator[x].classList.remove("activeIndicator")
}
}
carouselContainer.scrollLeft = (index * (eachCarousel + 10))
console.log(carouselContainer.scrollLeft)
}