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