-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (24 loc) · 819 Bytes
/
script.js
File metadata and controls
27 lines (24 loc) · 819 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
// Mobile nav toggle
const toggle = document.querySelector('.nav-toggle');
const nav = document.querySelector('#nav');
if (toggle) {
toggle.addEventListener('click', () => {
const isOpen = nav.classList.toggle('open');
toggle.setAttribute('aria-expanded', String(isOpen));
});
}
// Smooth scroll for same-page links
document.querySelectorAll('a[href^="#"]').forEach(a => {
a.addEventListener('click', e => {
const id = a.getAttribute('href').slice(1);
const el = document.getElementById(id);
if (el) {
e.preventDefault();
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
nav?.classList.remove('open');
toggle?.setAttribute('aria-expanded', 'false');
}
});
});
// Year in footer
document.getElementById('year').textContent = new Date().getFullYear();