-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (61 loc) · 2.5 KB
/
script.js
File metadata and controls
72 lines (61 loc) · 2.5 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
document.addEventListener('DOMContentLoaded', function() {
// --- SOLUÇÃO DE ANIMAÇÃO (FADE-IN) ---
const sections = document.querySelectorAll('.info-section');
if (window.IntersectionObserver) {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
sections.forEach(section => {
observer.observe(section);
});
} else {
sections.forEach(section => {
section.classList.add('visible');
});
}
// --- LÓGICA DE ROLAGEM SUAVE (ATUALIZADA) ---
// Seleciona TODOS os links do header (menu e logo)
document.querySelectorAll('.nav-links a, .logo-container').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const href = this.getAttribute('href');
if (href === '#top') {
// Se for o logo (#top), rolar para o topo absoluto
window.scrollTo({
top: 0,
behavior: "smooth"
});
} else {
// Para todos os outros links, usar a lógica de offset
const targetElement = document.querySelector(href);
if (targetElement) {
const headerOffset = 100; // Espaço do cabeçalho
const elementPosition = targetElement.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: "smooth"
});
}
}
});
});
// --- LÓGICA DO FAQ (ACORDEÃO) ---
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
const question = item.querySelector('.faq-question');
question.addEventListener('click', () => {
const isActive = item.classList.contains('active');
if (isActive) {
item.classList.remove('active');
} else {
item.classList.add('active');
}
});
});
});