File size: 1,877 Bytes
8d67e42 adbed4a 90a4273 8d67e42 adbed4a 8d67e42 adbed4a 90a4273 adbed4a 90a4273 adbed4a 90a4273 a301762 adbed4a a301762 90a4273 adbed4a a301762 90a4273 adbed4a 90a4273 | 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 |
// Duolingo-style animations
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
target.style.transform = 'translateY(-5px)';
setTimeout(() => {
target.style.transform = 'translateY(0)';
}, 300);
target.scrollIntoView({
behavior: 'smooth'
});
});
});
// Duolingo-style scroll animations
const animateOnScroll = () => {
const elements = document.querySelectorAll('.feature-card, .step, .hero-content');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animation = 'duoSlideUp 0.6s ease forwards';
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
elements.forEach(element => {
element.style.opacity = '0';
element.style.transform = 'translateY(20px)';
observer.observe(element);
});
};
// Add Duolingo-style animation
const style = document.createElement('style');
style.textContent = `
@keyframes duoSlideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
`;
document.head.appendChild(style);
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
animateOnScroll();
// Mobile menu toggle
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', () => {
const navLinks = document.querySelector('.nav-links');
navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex';
});
}
}); |