-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (33 loc) · 851 Bytes
/
index.js
File metadata and controls
37 lines (33 loc) · 851 Bytes
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
const header_img = document.querySelectorAll(".header-img");
const prev = document.querySelector(".control-prev");
const next = document.querySelector(".control-next");
let n = 0;
function hideimg(){
for(let i=0; i<header_img.length; i++){
header_img[i].style.display = "none";
}
header_img[n].style.display = "block";
}
prev.addEventListener('click',(e)=>{
if(n>0){
n--;
}else{
n = header_img.length -1;
}
hideimg();
})
next.addEventListener('click',(e)=>{
if(n<header_img.length -1){
n++;
}else{
n=0;
}
hideimg();
})
const scrollbar = document.querySelectorAll(".products");
for(const item of scrollbar){
item.addEventListener('wheel',(evt)=>{
evt.preventDefault();
item.scrollLeft += evt.deltaY;
})
}