-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (23 loc) · 812 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (23 loc) · 812 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
(() => {
// scroll reveal
const io = new IntersectionObserver((entries) => {
entries.forEach((e) => {
if (e.isIntersecting) {
e.target.classList.add('in');
io.unobserve(e.target);
}
});
}, { threshold: .12 });
document.querySelectorAll('.reveal').forEach((el) => io.observe(el));
// mobile menu toggle
const toggle = document.getElementById('navtoggle');
const links = document.getElementById('navlinks');
const setOpen = (open) => {
links.classList.toggle('open', open);
toggle.setAttribute('aria-expanded', String(open));
};
if (toggle && links) {
toggle.addEventListener('click', () => setOpen(!links.classList.contains('open')));
links.querySelectorAll('a').forEach((a) => a.addEventListener('click', () => setOpen(false)));
}
})();