-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (27 loc) · 935 Bytes
/
main.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
const header = document.querySelector("header");
window.addEventListener("scroll", function(){
header.classList.toggle("sticky", window.scrollY > 60)
});
document.addEventListener('DOMContentLoaded', function () {
let menu = document.querySelector('#menu-icon');
let navBar = document.querySelector('.navbar');
let menuItems = document.querySelectorAll('.navbar li a');
menu.onclick = () => {
menu.classList.toggle('bx-x');
navBar.classList.toggle('open');
};
menuItems.forEach(item => {
item.addEventListener('click', () => {
menu.classList.remove('bx-x');
navBar.classList.remove('open');
});
});
});
window.addEventListener('scroll', function() {
const header = document.querySelector('header');
if (window.scrollY > 550) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});