-
Notifications
You must be signed in to change notification settings - Fork 48
/
app.js
36 lines (33 loc) · 1.09 KB
/
app.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
const hamburgerMenu = document.querySelector('#navigation .nav-icon');
const navContent = document.querySelector('#nav-content');
const closeNavButton = document.querySelector('#nav-content .close-btn');
const navLinks = document.querySelectorAll('#nav-content nav ul li a');
const scrollButton = document.querySelector(".scroll-top");
// scroll TOP Button Events
if(scrollButton){
window.addEventListener('scroll', ()=> {
if(pageYOffset > (window.innerHeight * 1.2)){
scrollButton.style.display="flex";
}else{
scrollButton.style.display="none";
}
});
scrollButton.addEventListener("click", () => {
window.scrollTo(0, 0);
});
}
// Hamburger Menu events
hamburgerMenu.addEventListener('click', ()=>{
navContent.classList.add('show');
document.body.style.overflow="hidden";
});
closeNavButton.addEventListener('click', ()=>{
navContent.classList.remove('show');
document.body.style.overflow="initial";
});
navLinks.forEach( link => {
link.addEventListener('click', ()=> {
navContent.classList.remove('show');
document.body.style.overflow="initial";
})
})