darkwatch/site/main.js
2026-04-11 18:32:00 -04:00

24 lines
882 B
JavaScript

// Smooth scroll for anchor links (CSS scroll-behavior covers most cases,
// this handles the ↓ scroll-hint click on browsers that need it)
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', e => {
const target = document.querySelector(anchor.getAttribute('href'));
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
// Subtle parallax on hero background glow
const hero = document.querySelector('.hero');
if (hero) {
window.addEventListener('scroll', () => {
const scrolled = window.scrollY;
const heroHeight = hero.offsetHeight;
if (scrolled < heroHeight) {
// Move the pseudo-element glow upward slightly as user scrolls
hero.style.setProperty('--parallax-offset', `${scrolled * 0.3}px`);
}
}, { passive: true });
}