Beide Sites mit lokalem Font-Hosting, WebP, Build-Pipeline, SEO-Basis, HSTS, Performance-Tuning und aktualisierten Impressum/Datenschutz-Texten. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
var nav = document.getElementById('nav');
|
|
var navToggle = document.getElementById('navToggle');
|
|
var navMobile = document.getElementById('navMobile');
|
|
|
|
/* Navigation scroll effect */
|
|
if (nav) {
|
|
var scrolled = false;
|
|
window.addEventListener(
|
|
'scroll',
|
|
function () {
|
|
var shouldScroll = window.scrollY > 100;
|
|
if (shouldScroll === scrolled) return;
|
|
scrolled = shouldScroll;
|
|
nav.classList.toggle('scrolled', scrolled);
|
|
},
|
|
{ passive: true }
|
|
);
|
|
}
|
|
|
|
/* Mobile menu */
|
|
if (navToggle && navMobile) {
|
|
navToggle.addEventListener('click', function () {
|
|
var isOpen = navMobile.classList.toggle('active');
|
|
navToggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
|
});
|
|
|
|
navMobile.querySelectorAll('a').forEach(function (link) {
|
|
link.addEventListener('click', function () {
|
|
navMobile.classList.remove('active');
|
|
navToggle.setAttribute('aria-expanded', 'false');
|
|
});
|
|
});
|
|
}
|
|
|
|
/* Scroll reveal via IntersectionObserver */
|
|
var reveals = document.querySelectorAll('.reveal');
|
|
if (reveals.length && 'IntersectionObserver' in window) {
|
|
var observer = new IntersectionObserver(
|
|
function (entries) {
|
|
entries.forEach(function (entry) {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('active');
|
|
observer.unobserve(entry.target);
|
|
}
|
|
});
|
|
},
|
|
{ rootMargin: '0px 0px -80px 0px', threshold: 0.05 }
|
|
);
|
|
reveals.forEach(function (el) {
|
|
observer.observe(el);
|
|
});
|
|
} else {
|
|
reveals.forEach(function (el) {
|
|
el.classList.add('active');
|
|
});
|
|
}
|
|
|
|
/* Smooth scroll for anchor links */
|
|
document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
|
|
anchor.addEventListener('click', function (e) {
|
|
var href = this.getAttribute('href');
|
|
if (!href || href === '#') return;
|
|
var target = document.querySelector(href);
|
|
if (!target) return;
|
|
e.preventDefault();
|
|
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
});
|
|
});
|
|
})();
|