🐐
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// ── Nav: scroll state & active link ───────────────────────────
|
||||
(function () {
|
||||
const header = document.getElementById('header');
|
||||
const links = document.querySelectorAll('.nav-link');
|
||||
const sections = document.querySelectorAll('section[id]');
|
||||
const burger = document.getElementById('burger');
|
||||
if (!header || !burger) return;
|
||||
|
||||
window.addEventListener('scroll', () => {
|
||||
header.classList.toggle('scrolled', window.scrollY > 24 || burger.classList.contains('open'));
|
||||
|
||||
let current = '';
|
||||
sections.forEach(s => {
|
||||
if (window.scrollY >= s.offsetTop - 100) current = s.id;
|
||||
});
|
||||
links.forEach(l => {
|
||||
l.classList.toggle('active', l.getAttribute('href') === '#' + current);
|
||||
});
|
||||
}, { passive: true });
|
||||
})();
|
||||
Reference in New Issue
Block a user