alem-chto-ty-umeesh/script.js

66 lines
1.7 KiB
JavaScript

// FAQ Accordion
document.querySelectorAll('.faq-question').forEach(button => {
button.addEventListener('click', () => {
const item = button.parentElement;
const isActive = item.classList.contains('active');
document.querySelectorAll('.faq-item').forEach(i => i.classList.remove('active'));
if (!isActive) {
item.classList.add('active');
}
});
});
// Smooth scroll
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',
block: 'start'
});
}
});
});
// Header scroll effect
let lastScroll = 0;
const header = document.querySelector('.header');
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > 100) {
header.style.background = 'rgba(15, 23, 42, 0.98)';
} else {
header.style.background = 'rgba(15, 23, 42, 0.95)';
}
lastScroll = currentScroll;
});
// Animate elements 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.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
document.querySelectorAll('.feature-card, .instruction-category, .benefit-item, .faq-item').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});