-
Notifications
You must be signed in to change notification settings - Fork 3
/
slide.js
38 lines (36 loc) · 1.34 KB
/
slide.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
document.getElementById("1dots").style.opacity=1
const productContainers = [...document.querySelectorAll('.product-container')];
const nxtBtn = [...document.querySelectorAll('.nxt-btn')];
const preBtn = [...document.querySelectorAll('.pre-btn')];
console.log("jaySanodiya");
productContainers.forEach((item, i) => {
let containerDimensions = item.getBoundingClientRect();
let containerWidth = containerDimensions.width;
let count=1;
nxtBtn[i].addEventListener('click', () => {
console.log(count)
if(count==1){
document.getElementById("1dots").style.opacity=.3
document.getElementById("2dots").style.opacity=1
}
if(count==2){
document.getElementById("2dots").style.opacity=.3
document.getElementById("3dots").style.opacity=1
}
count++
item.scrollLeft += containerWidth;
})
preBtn[i].addEventListener('click', () => {
item.scrollLeft -= containerWidth;
count--
if(count==1){
document.getElementById("2dots").style.opacity=.3
document.getElementById("1dots").style.opacity=1
}
if(count==2){
document.getElementById("3dots").style.opacity=.3
document.getElementById("2dots").style.opacity=1
}
console.log(count)
})
})