-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
89 lines (71 loc) · 2.14 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
console.log("hello from sportsmonk!")
const swiper = new Swiper('#swiper-hero', {
// Optional parameters
direction: 'horizontal',
loop: true,
autoplay: {
delay: 2000,
},
// If we need pagination
pagination: {
el: '.swiper-pagination',
},
// Navigation arrows
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
new Swiper('#swiper-gallary',{
direction: 'horizontal',
loop: true,
slidesPerView: 1,
spaceBetween: 10,
autoplay: {
delay: 1000,
},
pagination: {
el: '.gallary-pagination',
type: 'bullets',
clickable: true
},
breakpoints: {
// when window width is >= 740px
740: {
slidesPerView: 4,
spaceBetween: 10
}
}
})
// cart menu
let cartMenu = document.querySelector('.cart-menu');
let cartMenuBtn = document.querySelector('.cart-menu-btn');
let cartMenuCrossBtn = document.querySelector('.cart-menu-cross-btn');
// show cart menu when cart-menu btn clicked
cartMenuBtn.addEventListener('click',function(event){
cartMenu.classList.add('cart-menu-active');
})
// hide cart menu when cart-menu-close btn clicked
cartMenuCrossBtn.addEventListener('click',function(event){
cartMenu.classList.remove('cart-menu-active');
})
// cart drawer
let cartDrawer = document.querySelector('.cart-drawer-section');
let cartDrawerBtn = document.querySelector('.cart-btn');
let cartDrawerCloseBtn = document.querySelector('.cart-drawer-cross-btn');
// show cart drawer when cart btn clicked
cartDrawerBtn.addEventListener('click',function(event){
cartDrawer.classList.add('cart-drawer-active');
})
// hide cart drawer when close btn clicked
cartDrawerCloseBtn.addEventListener('click',function(event){
cartDrawer.classList.remove('cart-drawer-active');
})
// product featured image change on clicked
let productFeaturedImg = document.querySelector('.product-featured-img')
let productThumbnailImgs = document.querySelectorAll('.product-other-img');
productThumbnailImgs.forEach(singleThumbnail => {
singleThumbnail.addEventListener('click',function(event){
productFeaturedImg.src = singleThumbnail.src;
})
})