-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (48 loc) · 1.77 KB
/
script.js
File metadata and controls
53 lines (48 loc) · 1.77 KB
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
document.addEventListener('DOMContentLoaded', () => {
// Меню мобильное
const btn = document.getElementById('menu-btn');
const nav = document.getElementById('menu');
btn.addEventListener('click', () => nav.classList.toggle('open'));
// Подсветка активной ссылки
document.querySelectorAll('nav a').forEach(link => {
if (link.href === location.href) {
link.classList.add('nav-link-active');
}
});
// Эффект «печатающегося» заголовка
const heroTitle = document.querySelector('.typewriter');
if (heroTitle) {
const text = heroTitle.dataset.text;
heroTitle.textContent = '';
let i = 0;
// создаём спэн-кульсор
const cursor = document.createElement('span');
cursor.classList.add('cursor');
cursor.textContent = '|';
heroTitle.appendChild(cursor);
const timer = setInterval(() => {
if (i < text.length) {
// вставляем текст и прикрепляем курсор
heroTitle.textContent = text.slice(0, i + 1);
heroTitle.appendChild(cursor);
i++;
} else {
clearInterval(timer);
}
}, 100);
}
// Анимация появления секций при скролле
const faders = document.querySelectorAll('.fade-in');
const observer = new IntersectionObserver(entries => {
entries.forEach(ent => {
if (ent.isIntersecting) {
ent.target.classList.add('opacity-100', 'translate-y-0');
observer.unobserve(ent.target);
}
});
}, { threshold: 0.2 });
faders.forEach(el => {
el.classList.add('opacity-0', 'translate-y-8', 'transition-all', 'duration-700');
observer.observe(el);
});
});