Spaces:
Running
Running
File size: 3,386 Bytes
6bf1f6c ec14f8b 6bf1f6c | 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
// Фильтрация проектов
document.addEventListener('DOMContentLoaded', function() {
// Фильтрация проектов в портфолио
const filterButtons = document.querySelectorAll('.filter-btn');
const projectItems = document.querySelectorAll('.project-item');
filterButtons.forEach(button => {
button.addEventListener('click', () => {
// Удаление активного класса у всех кнопок
filterButtons.forEach(btn => btn.classList.remove('active'));
// Добавление активного класса текущей кнопке
button.classList.add('active');
const filter = button.getAttribute('data-filter');
projectItems.forEach(item => {
if (filter === 'all' || item.getAttribute('data-category') === filter) {
item.classList.add('show');
item.classList.remove('hidden');
} else {
item.classList.remove('show');
item.classList.add('hidden');
}
});
});
});
// Анимация при прокрутке
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
}, observerOptions);
// Наблюдение за элементами с классом fade-in
document.querySelectorAll('.fade-in-element').forEach(el => {
observer.observe(el);
});
// Плавная прокрутка для якорных ссылок
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) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Анимация для hero-секции при загрузке
const heroTitle = document.querySelector('.hero-title');
const heroSubtitle = document.querySelector('.hero-subtitle');
const heroButtons = document.querySelector('.hero-buttons');
if (heroTitle) heroTitle.style.opacity = '0';
if (heroSubtitle) heroSubtitle.style.opacity = '0';
if (heroButtons) heroButtons.style.opacity = '0';
setTimeout(() => {
if (heroTitle) {
heroTitle.style.transition = 'opacity 1s ease-out';
heroTitle.style.opacity = '1';
}
if (heroSubtitle) {
heroSubtitle.style.transition = 'opacity 1s ease-out 0.3s';
heroSubtitle.style.opacity = '1';
}
if (heroButtons) {
heroButtons.style.transition = 'opacity 1s ease-out 0.6s';
heroButtons.style.opacity = '1';
}
}, 100);
});
|