Spaces:
Running
Running
File size: 982 Bytes
5a407e1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | // Shared JavaScript
document.addEventListener('DOMContentLoaded', () => {
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// Dynamic navbar background on scroll
const navbar = document.querySelector('custom-navbar').shadowRoot.querySelector('nav');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.style.background = 'rgba(17, 24, 39, 0.95)';
navbar.style.boxShadow = '0 4px 6px -1px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = '';
navbar.style.boxShadow = '';
}
});
}); |