Spaces:
Running
Running
File size: 1,813 Bytes
0a797e2 |
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 |
document.addEventListener('DOMContentLoaded', () => {
// Intersection Observer for fade-in animations on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: "0px 0px -50px 0px"
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fade-in-up');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Select elements to animate (headings, cards, sections)
const animatedElements = document.querySelectorAll('section h2, .grid > div, table, .bg-dark-800');
animatedElements.forEach(el => {
el.style.opacity = '0'; // Initial state
observer.observe(el);
});
// Simple Form Submission Handler (Prevent default for demo)
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', (e) => {
e.preventDefault();
const email = form.querySelector('input[type="email"]').value;
if(email) {
alert(`Thanks for signing up with ${email}! This is a demo.`);
}
});
// Handle button click specifically if not wrapped in form submit correctly or if type="button"
const btn = form.querySelector('button[type="button"]');
if(btn) {
btn.addEventListener('click', () => {
const email = form.querySelector('input[type="email"]').value;
if(email) {
alert(`Thanks for signing up with ${email}! This is a demo.`);
} else {
alert('Please enter an email address.');
}
});
}
});
}); |