25 lines
784 B
JavaScript
25 lines
784 B
JavaScript
// Javascript is active
|
|
document.documentElement.classList.remove('no-js');
|
|
|
|
// Update navigation according to page scroll
|
|
const options = {
|
|
rootMargin: '0px 0px -60% 0px'
|
|
};
|
|
const observer = new IntersectionObserver(entries => {
|
|
entries.forEach(entry => {
|
|
const id = entry.target.getAttribute("id");
|
|
if (entry.isIntersecting) {
|
|
document.querySelectorAll('[aria-current="page"]').forEach((z) => {
|
|
z.removeAttribute('aria-current', 'page')
|
|
});
|
|
const target = document.querySelector(`a[href="#${id}"]`);
|
|
if (target) {
|
|
document.querySelector(`a[href="#${id}"]`).setAttribute('aria-current', 'page');
|
|
}
|
|
}
|
|
});
|
|
},options);
|
|
|
|
document.querySelectorAll('section').forEach(function(section, i) {
|
|
observer.observe(section);
|
|
}); |