-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
199 lines (185 loc) · 7.55 KB
/
script.js
File metadata and controls
199 lines (185 loc) · 7.55 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
// --- MODO ESCURO COMENTADO ---
// Função para alternar o tema
function toggleTheme() {
const html = document.documentElement;
const currentTheme = html.getAttribute('data-theme');
if (currentTheme === 'dark') {
html.removeAttribute('data-theme');
localStorage.setItem('theme', 'light');
document.querySelector('#themeToggle i').classList.remove('fa-sun');
document.querySelector('#themeToggle i').classList.add('fa-moon');
} else {
html.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
document.querySelector('#themeToggle i').classList.remove('fa-moon');
document.querySelector('#themeToggle i').classList.add('fa-sun');
}
}
// Verificar tema salvo
document.addEventListener('DOMContentLoaded', () => {
const themeToggle = document.getElementById('themeToggle');
const html = document.documentElement;
const icon = themeToggle.querySelector('i');
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
html.setAttribute('data-theme', savedTheme);
icon.classList.remove('fa-moon', 'fa-sun');
icon.classList.add(savedTheme === 'dark' ? 'fa-sun' : 'fa-moon');
}
themeToggle.addEventListener('click', () => {
const currentTheme = html.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
html.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
icon.classList.remove('fa-moon', 'fa-sun');
icon.classList.add(newTheme === 'dark' ? 'fa-sun' : 'fa-moon');
});
});
*/
// Smooth scrolling for anchor links
document.addEventListener('DOMContentLoaded', function() {
const links = document.querySelectorAll('a[href^="#"]');
links.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
const headerHeight = 60;
const targetPosition = targetElement.offsetTop - headerHeight;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// Efeito de reveal
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
const cards = document.querySelectorAll('.mvv-card, .equipe-card, .diferencial-card, .testimonial-card, .produto-card');
cards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
// Carrossel Nossa Identidade
const identidadeScroll = document.getElementById('identidadeScroll');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const indicatorsContainer = document.getElementById('identidadeIndicators');
if (identidadeScroll && prevBtn && nextBtn && indicatorsContainer) {
class Carousel {
constructor() {
this.track = identidadeScroll;
this.prevBtn = prevBtn;
this.nextBtn = nextBtn;
this.indicatorsContainer = indicatorsContainer;
this.currentIndex = 0;
this.totalCards = 7;
this.cardsPerView = 3;
this.maxIndex = this.totalCards - this.cardsPerView;
this.autoPlayInterval = null;
this.init();
}
init() {
this.createIndicators();
this.updateButtons();
this.updateIndicators();
this.bindEvents();
}
createIndicators() {
for (let i = 0; i <= this.maxIndex; i++) {
const indicator = document.createElement('div');
indicator.className = 'identidade-indicator';
indicator.addEventListener('click', () => this.goToSlide(i));
this.indicatorsContainer.appendChild(indicator);
}
}
bindEvents() {
this.prevBtn.addEventListener('click', () => this.prevSlide());
this.nextBtn.addEventListener('click', () => this.nextSlide());
this.track.addEventListener('mouseenter', () => this.pauseAutoPlay());
this.track.addEventListener('mouseleave', () => this.startAutoPlay());
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft') this.prevSlide();
else if (e.key === 'ArrowRight') this.nextSlide();
});
}
goToSlide(index) {
if (index < 0 || index > this.maxIndex) return;
this.currentIndex = index;
this.updateTrack();
this.updateButtons();
this.updateIndicators();
}
prevSlide() {
if (this.currentIndex > 0) {
this.goToSlide(this.currentIndex - 1);
} else {
this.goToSlide(this.maxIndex);
}
}
nextSlide() {
if (this.currentIndex < this.maxIndex) {
this.goToSlide(this.currentIndex + 1);
} else {
this.goToSlide(0);
}
}
updateTrack() {
const cardWidth = 100 / this.cardsPerView;
const translateX = -(this.currentIndex * cardWidth);
this.track.style.transform = `translateX(${translateX}%)`;
}
updateButtons() {
this.prevBtn.disabled = this.currentIndex === 0;
this.nextBtn.disabled = this.currentIndex === this.maxIndex;
}
updateIndicators() {
const indicators = this.indicatorsContainer.querySelectorAll('.identidade-indicator');
indicators.forEach((indicator, index) => {
indicator.classList.toggle('active', index === this.currentIndex);
});
}
startAutoPlay() {
this.autoPlayInterval = setInterval(() => {
this.nextSlide();
}, 5000);
}
pauseAutoPlay() {
if (this.autoPlayInterval) {
clearInterval(this.autoPlayInterval);
}
}
}
const carousel = new Carousel();
carousel.startAutoPlay();
}
// --- MENU HAMBÚRGUER ---
const menuToggle = document.getElementById("menuToggle");
const navMenu = document.querySelector(".nav-menu");
if (menuToggle && navMenu) {
menuToggle.addEventListener("click", function () {
navMenu.classList.toggle("show");
});
// Fecha o menu ao clicar em um link
document.querySelectorAll(".nav-menu a").forEach(link => {
link.addEventListener("click", () => {
navMenu.classList.remove("show");
});
});
}
});