-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
29 lines (25 loc) · 703 Bytes
/
main.js
File metadata and controls
29 lines (25 loc) · 703 Bytes
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
let menu = document.querySelector("header .container .links");
let menuList = document.querySelector("header .container .links ul");
let scrollToTopBtn = document.querySelector(".scroll-to-top");
menu.onclick = function () {
menuList.style.display = "block";
};
document.addEventListener("mouseup", function (e) {
let container = menuList;
if (!container.contains(e.target)) {
container.style.display = "none";
}
});
window.onscroll = function () {
if (this.scrollY >= 574) {
scrollToTopBtn.classList.add("show");
} else {
scrollToTopBtn.classList.remove("show");
}
};
scrollToTopBtn.onclick = function () {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};