-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (28 loc) · 1.06 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
document.querySelector("#menu").addEventListener("click", () => {
document.querySelector("#nav").style.left ='0';
document.querySelector("#exit").style.display = "block";
});
document.querySelector("#exit").addEventListener("click", () =>{
document.querySelector("#nav").style.left ='-100%';
document.querySelector("#exit").style.display ="none";
})
var prevScrollpos = window.pageYOffset;
window.onscroll = () => {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("nav").style.left = "-100%";
document.getElementById("navBar").style.top = "0";
} else {
document.getElementById("nav").style.left = "-100%";
document.getElementById("nav").style.top = "0";
document.getElementById("navBar").style.top = "-6rem";
}
prevScrollpos = currentScrollPos;
}
let modal = document.getElementById("nav");
window.onclick = function(event) {
if (event.target == modal) {
document.getElementById("exit").style.display = "none";
modal.style.left = "-100%";
}
}