-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
134 lines (117 loc) · 3.85 KB
/
script.js
File metadata and controls
134 lines (117 loc) · 3.85 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
const slides = document.querySelectorAll('.slide');
const dots = document.querySelectorAll('.dot');
let index = 0;
// Criar estrelas
const starsContainer = document.getElementById('stars');
for (let i = 0; i < 50; i++) {
const star = document.createElement('div');
star.className = 'star';
star.style.left = Math.random() * 100 + '%';
star.style.top = Math.random() * 100 + '%';
star.style.animationDelay = Math.random() * 3 + 's';
starsContainer.appendChild(star);
}
// Corações flutuantes
function createHeart() {
const heart = document.createElement('div');
heart.className = 'heart-float';
heart.textContent = '💜';
heart.style.left = Math.random() * 100 + '%';
heart.style.bottom = '-50px';
heart.style.animationDelay = Math.random() * 2 + 's';
document.body.appendChild(heart);
setTimeout(() => heart.remove(), 4000);
}
setInterval(createHeart, 3000);
// Navegação entre slides
function showSlide(newIndex) {
slides[index].classList.remove('active');
dots[index].classList.remove('active');
index = newIndex;
slides[index].classList.add('active');
dots[index].classList.add('active');
}
document.getElementById('next').addEventListener('click', () => {
showSlide((index + 1) % slides.length);
});
document.getElementById('prev').addEventListener('click', () => {
showSlide((index - 1 + slides.length) % slides.length);
});
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowRight') {
document.getElementById('next').click();
} else if (e.key === 'ArrowLeft') {
document.getElementById('prev').click();
}
});
// Coração secreto interativo
let clickCount = 0;
const secretHeart = document.getElementById('secretHeart');
const clickCounter = document.getElementById('clickCounter');
const letterModal = document.getElementById('letterModal');
const closeLetter = document.getElementById('closeLetter');
secretHeart.addEventListener('click', () => {
clickCount++;
// Feedback visual
secretHeart.style.transform = 'scale(1.3)';
setTimeout(() => {
secretHeart.style.transform = 'scale(1)';
}, 200);
// Mostrar contador após 5 cliques
if (clickCount >= 5 && clickCount < 22) {
clickCounter.textContent = `${clickCount}/22 ✨`;
}
// Abrir carta aos 22 cliques
if (clickCount === 22) {
clickCounter.textContent = '💜 Abrindo sua carta...';
setTimeout(() => {
letterModal.classList.add('show');
// Efeito confete
for (let i = 0; i < 30; i++) {
setTimeout(() => createHeart(), i * 100);
}
}, 500);
}
});
closeLetter.addEventListener('click', () => {
letterModal.classList.remove('show');
});
letterModal.addEventListener('click', (e) => {
if (e.target === letterModal) {
letterModal.classList.remove('show');
}
});
// ========================================
// CONTROLE DE MÚSICA
// ========================================
const backgroundMusic = document.getElementById('backgroundMusic');
const musicToggle = document.getElementById('musicToggle');
let isPlaying = false;
musicToggle.addEventListener('click', () => {
if (isPlaying) {
backgroundMusic.pause();
musicToggle.classList.remove('playing');
musicToggle.classList.add('paused');
isPlaying = false;
} else {
backgroundMusic.play().catch(error => {
console.log('Erro ao reproduzir música:', error);
});
musicToggle.classList.add('playing');
musicToggle.classList.remove('paused');
isPlaying = true;
}
});
// Tentar reproduzir automaticamente no primeiro clique
document.addEventListener('click', function initMusic() {
if (!isPlaying) {
backgroundMusic.play().then(() => {
musicToggle.classList.add('playing');
isPlaying = true;
}).catch(() => {
// Se falhar, o usuário precisa clicar no botão
musicToggle.classList.add('paused');
});
}
document.removeEventListener('click', initMusic);
}, { once: true });