-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
33 lines (29 loc) · 884 Bytes
/
main.js
File metadata and controls
33 lines (29 loc) · 884 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
30
31
32
33
// Search box toggle
let search = document.querySelector('.search-box');
let searchIcon = document.querySelector('#search-icon');
if (searchIcon) {
searchIcon.onclick = () => {
search.classList.toggle('active');
menu.classList.toggle('active');
};
}
// Navbar menu toggle
let menu = document.querySelector('.navbar');
let menuIcon = document.querySelector('#menu-icon');
if (menuIcon) {
menuIcon.onclick = () => {
menu.classList.toggle('active');
menu.classList.remove('active');
};
}
window.onscroll=()=>{
menu.classList.remove('active');
search.classList.remove('active');
}
// Header shadow effect on scroll
let header = document.querySelector('header');
if (header) {
window.addEventListener('scroll', () => {
header.classList.toggle('shadow', window.scrollY > 0);
});
}