-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.js
80 lines (57 loc) · 1.5 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
const swiper = new Swiper('.swiper', {
autoplay: {
delay : 3000,
disableOnInteraction : false,
},
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
// user section
function menuToggle(){
let toggleMenu = document.querySelector(".menu");
toggleMenu.classList.toggle('active')
}
// homepage script
let flag=0;
function controller(x){
flag=flag+x;
slideshow(flag);
}
slideshow(flag);
function slideshow(num){
let slides=document.getElementsByClassName("bigimage");
if(num>slides.length){
flag=0;
num=0;
}
if(num<0){
flag=slides.length-1;
num=slides.length-1;
}
//console.log(slides)
for(let y of slides){
y.style.display="none";
}
slides[num].style.display="block";
}
// what's in the bag js
const productContainers = [...document.querySelectorAll('.product-container')];
const nxtBtn = [...document.querySelectorAll('.nxt-btn')];
const preBtn = [...document.querySelectorAll('.pre-btn')];
productContainers.forEach((item, i) => {
let containerDimensions = item.getBoundingClientRect();
let containerWidth = containerDimensions.width;
nxtBtn[i].addEventListener('click', () => {
item.scrollLeft += containerWidth;
})
preBtn[i].addEventListener('click', () => {
item.scrollLeft -= containerWidth;
})
})