File size: 2,517 Bytes
c52ddda | 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | // Main JavaScript file for global functionality
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle functionality will be handled by the header component
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
const headerOffset = 80;
const elementPosition = targetElement.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
});
});
// Animation on scroll
const animateOnScroll = function() {
const elements = document.querySelectorAll('.fade-in');
elements.forEach(element => {
const elementTop = element.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
if (elementTop < windowHeight - 100) {
element.classList.add('opacity-100', 'translate-y-0');
}
});
};
// Initialize elements with fade-in effect
document.querySelectorAll('.feature-card, .testimonial').forEach((el, index) => {
el.classList.add('fade-in', 'opacity-0', 'translate-y-6', 'transition-all', 'duration-500', 'ease-out');
el.style.transitionDelay = `${index * 100}ms`;
});
window.addEventListener('scroll', animateOnScroll);
animateOnScroll(); // Initial check
});
// Form validation for demo requests
function validateForm(form) {
const email = form.querySelector('input[type="email"]');
const name = form.querySelector('input[type="text"]');
let isValid = true;
if (!name.value.trim()) {
name.classList.add('border-red-500');
isValid = false;
} else {
name.classList.remove('border-red-500');
}
if (!email.value.trim() || !email.value.includes('@')) {
email.classList.add('border-red-500');
isValid = false;
} else {
email.classList.remove('border-red-500');
}
return isValid;
} |