forked from Vin-Jex/dent-clack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
133 lines (116 loc) · 2.81 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/** @format */
const toggle = document.querySelector(".toggle");
const nav = document.querySelector(".nav-main");
let lists = document.querySelectorAll(".navlinks");
// const linkContainer = document.querySelector(".links")
/* Toggle Nav */
toggle.addEventListener("click", () => {
toggle.classList.toggle("show-nav");
nav.classList.toggle("show-nav");
});
// lists.forEach((btn) => {
// btn.addEventListener("click", (e) => {
// lists.forEach(Element => {
// Element.classList.remove("active")
// console.log("yo");
// })
// e.target.classList.add("active")
// })
// })
lists.forEach((btn) => {
btn.addEventListener("click", (element) => {
lists.forEach((link) => link.classList.remove("active"));
element.target.classList.add("active");
});
});
/* Target button
Give it a single name on small screen
*/
window.addEventListener("DOMContentLoaded", () => {
const screenWidth = window.innerWidth;
const appointment = document.querySelector("#appointment");
const play = document.querySelector("#play");
if (screenWidth <= 784) {
appointment.innerHTML = "Book";
let icon = document.createElement("span");
icon.classList.add("material-symbols-outlined");
const iconName = document.createTextNode("add");
icon.appendChild(iconName);
appointment.append(icon);
}
});
/* Static Nav bar */
const header = document.querySelector("#header");
const sticky = header.offsetTop;
window.onscroll = () => {
if (window.pageYOffset >= sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
};
/* Swiper js function */
const swiper = new Swiper(".swiper", {
// Optional parameters
direction: "horizontal",
loop: true,
slidesPerView: 1,
spaceBetween: 30,
grabCursor: true,
speed: 500,
keyboard: {
enabled: true,
},
breakpoints: {
640: {
slidesPerView: 2,
},
1024: {
slidesPerView: 3,
},
},
// If we need pagination
pagination: {
el: ".swiper-pagination",
clickable: true,
},
// Navigation arrows
// navigation: {
// nextEl: ".swiper-button-next",
// prevEl: ".swiper-button-prev",
// },
// And if we need scrollbar
// scrollbar: {
// el: ".swiper-scrollbar",
// },
});
/* Swiper js function */
const swiper2 = new Swiper(".testimonials", {
// Optional parameters
direction: "horizontal",
slidesPerView: 1,
spaceBetween: 30,
grabCursor: true,
speed: 500,
keyboard: {
enabled: true,
},
pagination: {
el: ".swiper-pagination2",
clickable: true,
},
breakpoints: {
640: {
spaceBetween: 40,
},
},
// Navigation arrows
// navigation: {
// nextEl: ".swiper-button-next",
// prevEl: ".swiper-button-prev",
// },
// And if we need scrollbar
// scrollbar: {
// el: ".swiper-scrollbar",
// },
});