-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
213 lines (183 loc) · 6.97 KB
/
script.js
File metadata and controls
213 lines (183 loc) · 6.97 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
document.addEventListener('DOMContentLoaded', function() {
const yesBtn = document.getElementById('yesBtn');
const noBtn = document.getElementById('noBtn');
const container = document.querySelector('.container');
const scrollIndicator = document.querySelector('.scroll-indicator');
const lovePreview = document.getElementById('lovePreview');
// Scroll indicator functionality
let scrollTimeout;
// Handle scroll indicator click
scrollIndicator.addEventListener('click', function() {
showLovePreview();
});
// Show love preview on scroll
window.addEventListener('scroll', function() {
clearTimeout(scrollTimeout);
scrollTimeout = setTimeout(function() {
if (window.scrollY > 50) {
showLovePreview();
}
}, 100);
});
function showLovePreview() {
lovePreview.classList.add('visible');
scrollIndicator.style.opacity = '0';
// Hide scroll indicator after preview shows
setTimeout(() => {
scrollIndicator.style.display = 'none';
}, 500);
}
// Make NO button run away on hover
noBtn.addEventListener('mouseenter', function() {
moveNoButton();
});
// Also make NO button run away on touch for mobile
noBtn.addEventListener('touchstart', function(e) {
e.preventDefault();
moveNoButton();
});
function moveNoButton() {
const containerRect = container.getBoundingClientRect();
const buttonRect = noBtn.getBoundingClientRect();
// Calculate safe boundaries
const maxX = containerRect.width - buttonRect.width - 40;
const maxY = containerRect.height - buttonRect.height - 40;
// Generate random position within bounds
const randomX = Math.random() * maxX;
const randomY = Math.random() * maxY;
// Apply random position
noBtn.style.position = 'absolute';
noBtn.style.left = randomX + 'px';
noBtn.style.top = randomY + 'px';
noBtn.style.transition = 'all 0.3s ease';
// Add a little fun animation
noBtn.style.transform = `rotate(${Math.random() * 20 - 10}deg) scale(${0.9 + Math.random() * 0.2})`;
// Reset transform after animation
setTimeout(() => {
noBtn.style.transform = 'rotate(0deg) scale(1)';
}, 300);
}
// Handle YES button click - transition to celebration
yesBtn.addEventListener('click', function() {
// Create celebration effect
createCelebrationEffect();
// Transition to love page after a short delay
setTimeout(() => {
window.location.href = 'love.html';
}, 1500);
});
function createCelebrationEffect() {
// Create multiple hearts that burst from the button
for (let i = 0; i < 20; i++) {
setTimeout(() => {
createBurstHeart();
}, i * 50);
}
// Add celebration class to button
yesBtn.classList.add('celebrating');
yesBtn.textContent = 'YESSS! ';
}
function createBurstHeart() {
const heart = document.createElement('div');
heart.innerHTML = '';
heart.style.position = 'fixed';
heart.style.fontSize = Math.random() * 20 + 15 + 'px';
heart.style.left = '50%';
heart.style.top = '50%';
heart.style.transform = 'translate(-50%, -50%)';
heart.style.pointerEvents = 'none';
heart.style.zIndex = '9999';
heart.style.animation = `burstHeart ${Math.random() * 2 + 1}s ease-out forwards`;
document.body.appendChild(heart);
// Remove heart after animation
setTimeout(() => {
heart.remove();
}, 3000);
}
// Add burst heart animation dynamically
const style = document.createElement('style');
style.textContent = `
@keyframes burstHeart {
0% {
transform: translate(-50%, -50%) scale(0) rotate(0deg);
opacity: 1;
}
50% {
transform: translate(calc(-50% + ${Math.random() * 400 - 200}px), calc(-50% + ${Math.random() * 400 - 200}px)) scale(1.5) rotate(${Math.random() * 360}deg);
opacity: 1;
}
100% {
transform: translate(calc(-50% + ${Math.random() * 600 - 300}px), calc(-50% + ${Math.random() * 600 - 300}px)) scale(0.5) rotate(${Math.random() * 720}deg);
opacity: 0;
}
}
.celebrating {
animation: celebrateButton 0.5s ease-in-out infinite alternate !important;
}
@keyframes celebrateButton {
from {
transform: scale(1) rotate(-5deg);
background: linear-gradient(135deg, #ff6b9d, #e91e63);
}
to {
transform: scale(1.1) rotate(5deg);
background: linear-gradient(135deg, #e91e63, #ff6b9d);
}
}
`;
document.head.appendChild(style);
// Add some ambient floating hearts to the landing page
createAmbientHearts();
});
function createAmbientHearts() {
// Create a few ambient floating hearts
for (let i = 0; i < 5; i++) {
setTimeout(() => {
createAmbientHeart();
}, i * 2000);
}
// Continue creating ambient hearts
setInterval(() => {
createAmbientHeart();
}, 3000);
}
function createAmbientHeart() {
const heart = document.createElement('div');
heart.innerHTML = [' ', ' ', ' ', ' ', ' '][Math.floor(Math.random() * 5)];
heart.style.position = 'fixed';
heart.style.fontSize = Math.random() * 15 + 10 + 'px';
heart.style.left = Math.random() * window.innerWidth + 'px';
heart.style.bottom = '-50px';
heart.style.pointerEvents = 'none';
heart.style.zIndex = '1';
heart.style.animation = `ambientFloat ${Math.random() * 5 + 8}s linear forwards`;
heart.style.opacity = Math.random() * 0.3 + 0.2;
document.body.appendChild(heart);
// Remove heart after animation
setTimeout(() => {
heart.remove();
}, 13000);
}
// Add ambient float animation
const ambientStyle = document.createElement('style');
ambientStyle.textContent = `
@keyframes ambientFloat {
0% {
bottom: -50px;
transform: translateX(0) rotate(0deg);
opacity: 0;
}
10% {
opacity: 0.5;
}
90% {
opacity: 0.5;
}
100% {
bottom: 110vh;
transform: translateX(${Math.random() * 200 - 100}px) rotate(360deg);
opacity: 0;
}
}
`;
document.head.appendChild(ambientStyle);