-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
70 lines (56 loc) · 1.87 KB
/
main.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
/*=============== SHOW MENU ===============*/
const navMenu = document.getElementById('nav-menu'),
navToggle = document.getElementById('nav-toggle'),
navClose = document.getElementById('nav-close')
/*===== MENU SHOW =====*/
/* Validate if constant exists */
if(navToggle){
navToggle.addEventListener('click', () =>{
navMenu.classList.add('show-menu')
})
}
/*===== MENU HIDDEN =====*/
/* Validate if constant exists */
if(navClose){
navClose.addEventListener('click', () =>{
navMenu.classList.remove('show-menu')
})
}
/*=============== REMOVE MENU MOBILE ===============*/
const navLink = document.querySelectorAll('.nav__link')
const linkAction = () =>{
const navMenu = document.getElementById('nav-menu')
// When we click on each nav__link, we remove the show-menu class
navMenu.classList.remove('show-menu')
}
navLink.forEach(n => n.addEventListener('click', linkAction))
/*=============== SWIPER SHOE ===============*/
let swiperShoes = new Swiper(".home__swiper", {
// Optional parameters
loop: true,
spaceBetween: 32,
grabCursor: true,
effect: "creative",
creativeEffect:{
prev:{
translate: [-100, 0, -500],
opacity: 0,
},
next:{
translate: [100, 0, -500],
opacity: 0,
},
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
})
/*=============== SHADOW HEADER ===============*/
const blurHeader = () =>{
const header = document.getElementById('header')
// When the scroll is greater than 50 viewport height, add the background-header class to the header tag
this.scrollY >= 50 ? header.classList.add('shadow-header')
: header.classList.remove('shadow-header')
}
window.addEventListener('scroll', blurHeader)