-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
55 lines (48 loc) · 1.3 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
const navItems = document.querySelector("#nav__items");
const openNavBtn = document.querySelector("#open__nav-btn");
const closeNavBtn = document.querySelector("#close__nav-btn");
openNavBtn.addEventListener("click", () => {
navItems.style.display = "flex";
closeNavBtn.style.display = "inline-block";
openNavBtn.style.display = "none";
});
const closeNav = () => {
navItems.style.display = "none";
closeNavBtn.style.display = "none";
openNavBtn.style.display = "inline-block";
};
closeNavBtn.addEventListener("click", closeNav);
// close nav when a menu item is clicked
if (window.innerWidth < 1024) {
document.querySelectorAll("#nav__items li a").forEach((navItem) => {
navItem.addEventListener("click", () => {
closeNav();
});
});
}
// change navbar styles on scroll
window.addEventListener("scroll", () => {
document
.querySelector("nav")
.classList.toggle("window-scroll", window.scrollY > 0);
});
// Initialize Swiper
var swiper = new Swiper(".mySwiper", {
slidesPerView: 1,
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
// responsive breakpoints
breakpoints: {
//when window width is >= 600px
600: {
slidesPerView: 2,
},
//when window width is >= 1024px
1024: {
slidesPerView: 3,
},
},
});