2025-10-07 16:55:35 +00:00

37 lines
1.1 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function () {
// Sticky header
const navbar = document.querySelector('.navbar');
if (navbar) {
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('navbar-sticky');
} else {
navbar.classList.remove('navbar-sticky');
}
});
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Contact form validation
const contactForm = document.getElementById('contactForm');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
if (!this.checkValidity()) {
e.preventDefault();
e.stopPropagation();
}
this.classList.add('was-validated');
}, false);
}
});