forked from RamziBach/Portfolio-OLD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (19 loc) · 1.01 KB
/
script.js
File metadata and controls
22 lines (19 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const hamburger = document.querySelectorAll('.hamburger');
const mobileNav = document.querySelector('.hamburger-container');
const clear = document.querySelector('.clear');
const containerSticky = document.querySelector('.sticky-header');
const closeNav = document.querySelectorAll('.hamburger-li');
hamburger[0].addEventListener('click', () => mobileNav.style.display = 'block');
hamburger[1].addEventListener('click', () => mobileNav.style.display = 'block');
clear.addEventListener('click', () => mobileNav.style.display = 'none');
closeNav[0].addEventListener('click', () => mobileNav.style.display = 'none');
closeNav[1].addEventListener('click', () => mobileNav.style.display = 'none');
closeNav[2].addEventListener('click', () => mobileNav.style.display = 'none');
const scrollFunction = () => {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
containerSticky.style.display = "block";
} else {
containerSticky.style.display = "none";
}
};
window.onscroll = () => scrollFunction();