-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (36 loc) · 1.02 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
// Add an event listener to the nav toggle button
document.querySelector(".nav-toggle").addEventListener("click", function () {
document.querySelector(".navigation-menu").classList.toggle("show");
document.querySelector(".navigation-menu").classList.toggle("slide-in");
});
// scrollup-btn
window.addEventListener("scroll", function () {
var clientHeight = 400;
var scrollPosition =
window.scrollY ||
document.documentElement.scrollTop ||
document.body.scrollTop ||
0;
if (scrollPosition >= clientHeight) {
document.querySelector(".scroll-up-button").style.display = "block";
} else {
document.querySelector(".scroll-up-button").style.display = "none";
}
});
document
.querySelector(".scroll-up-button")
.addEventListener("click", function (event) {
event.preventDefault();
window.scrollTo({
top: 0,
behavior: "smooth",
});
});
var splide = new Splide(".splide", {
type: "loop",
perPage: 1,
perMove: 1,
// padding: "1rem",
focus: "center",
});
splide.mount();