First version of the new layout.
This commit is contained in:
47
DouwcoWebsite/wwwroot/js/index.js
Normal file
47
DouwcoWebsite/wwwroot/js/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// Setup the navigation bar
|
||||
function setupNavigationHighlight(){
|
||||
const sections = document.querySelectorAll('.scroll_section');
|
||||
const navOptions = document.querySelectorAll('.nav_option');
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
const sectionId = entry.target.id;
|
||||
window.history.pushState(null, null, `#${sectionId}`);
|
||||
navOptions.forEach(link => {
|
||||
link.classList.remove('active');
|
||||
if (link.getAttribute('href') === `#${sectionId}`) {
|
||||
link.classList.add('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
}), {threshold: 0.5};
|
||||
})
|
||||
|
||||
sections.forEach(section => {
|
||||
observer.observe(section);
|
||||
});
|
||||
}
|
||||
|
||||
function setupNavigationClickObserver() {
|
||||
const navLinks = document.querySelectorAll('.nav_option');
|
||||
navLinks.forEach(link => {
|
||||
link.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const targetId = link.getAttribute('href');
|
||||
const targetSection = document.querySelector(targetId);
|
||||
if (targetSection) {
|
||||
targetSection.scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setupNavigationHighlight();
|
||||
setupNavigationClickObserver();
|
||||
|
||||
// Set copyright year
|
||||
const currentYear = new Date().getFullYear();
|
||||
document.getElementById('copyright').textContent = `© ${currentYear} - douwco.be`;
|
||||
Reference in New Issue
Block a user