ok
Some checks are pending
www2.ourworld.tf / Deploy (push) Waiting to run

This commit is contained in:
2025-09-10 16:37:21 +02:00
parent ee4c652b5b
commit 141151bcec
7 changed files with 40 additions and 19 deletions

View File

@@ -104,6 +104,31 @@ function toggleFilter() {
filterMenu.className = filterMenu.className + " hidden"
}
}
// Smooth scrolling function for anchor links
function smoothScrollToElement(targetId) {
const element = document.getElementById(targetId);
if (element) {
const headerHeight = document.getElementById('header-container') ?
document.getElementById('header-container').offsetHeight : 80;
const elementPosition = element.offsetTop - headerHeight - 20;
window.scrollTo({
top: elementPosition,
behavior: 'smooth'
});
}
}
// Handle anchor link clicks
function handleAnchorClick(event, link) {
const href = link.getAttribute('href');
if (href && href.startsWith('#')) {
event.preventDefault();
const targetId = href.substring(1);
smoothScrollToElement(targetId);
}
}
window.onload = function () {
let elements = document.getElementsByTagName("button");
let buttons = [...elements]
@@ -126,8 +151,18 @@ window.onload = function () {
if (!internal_hosts.includes(links[i].hostname)) {
links[i].target = '_blank';
}
// Add smooth scrolling for anchor links
if (links[i].getAttribute('href') && links[i].getAttribute('href').startsWith('#')) {
links[i].addEventListener('click', function(event) {
handleAnchorClick(event, this);
});
}
}
// Add smooth scrolling behavior to html element
document.documentElement.style.scrollBehavior = 'smooth';
document.getElementById("filter-btn").addEventListener('click', toggleFilter);
}