-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (19 loc) · 795 Bytes
/
script.js
File metadata and controls
23 lines (19 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.querySelector(".hamburger-menu").addEventListener("click", () => {
document.querySelector(".container").classList.toggle("change");
});
document.querySelector(".scroll-btn").addEventListener("click", () => {
document.querySelector("html").style.scrollBehavior = "smooth";
setTimeout(() => {
document.querySelector("html").style.scrollBehavior = "unset";
}, 1000);
});
var rootElement = document.documentElement
function handleScroll() {
var scrollTotal = rootElement.scrollHeight - rootElement.clientHeight
if ( ( rootElement.scrollTop / scrollTotal ) > 0.95 ) {
document.querySelector(".scroll-btn").classList.add("showBtn")
} else {
document.querySelector(".scroll-btn").classList.remove("showBtn")
}
}
document.addEventListener("scroll", handleScroll)