-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlove.html
More file actions
287 lines (246 loc) Β· 11.7 KB
/
love.html
File metadata and controls
287 lines (246 loc) Β· 11.7 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Yes! My Valentine - Valary</title>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<style>
html {
scroll-behavior: smooth; /* Native smooth scrolling (much faster than JS) */
}
/* Disable heavy blur effects on the main card to fix scroll lag */
.love-letter {
backdrop-filter: none !important;
-webkit-backdrop-filter: none !important;
background: rgba(255, 255, 255, 0.95) !important; /* Slightly more opaque to compensate */
transform: translateZ(0); /* Hardware acceleration hack */
}
/* Optimize animations */
.heart, .floating-hearts div {
will-change: transform; /* Tells browser to optimize these layers */
}
</style>
</head>
<body>
<div class="floating-hearts" id="heartsContainer"></div>
<div class="scroll-indicator">
<div class="scroll-text">Scroll down</div>
<div class="scroll-arrow">β</div>
</div>
<div class="container">
<div class="love-letter">
<div class="letter-header">
<h1>My Dearest Valary,</h1>
<div class="decorative-line"></div>
</div>
<div class="letter-body">
<p>
I didn't want to just buy a card or send a text, because you deserve more than that.
I wanted to build something strictly for you, line by line, to show you how much you mean to me.
</p>
<p>
In a world full of variables and chaos, you are my only constant.
You are the CSS to my HTMLβwithout you, my life would just be plain structure with no style, color, or beauty.
</p>
<p>
Thank you for being my peace, my motivation, and my best friend.
My heart is open-source, but it's dedicated 100% to you.
</p>
</div>
<div class="letter-footer">
<div class="decorative-line"></div>
<p class="signature">
Happy Valentine's Day! β€οΈ<br>
<strong>β Emmanuel Kibet</strong>
</p>
<div class="hearts-decoration">π π π</div>
</div>
</div>
<button id="scrollToTop" class="scroll-to-top" title="Scroll to top">
β
</button>
<div id="scrollUpArrow" class="scroll-up-arrow" title="Scroll to top">
<div class="arrow-icon">β</div>
<div class="arrow-text">Top</div>
</div>
<footer class="signature">
<p>Forever yours, Emmanuel Kibet π</p>
</footer>
</div>
<audio id="romanticMusic" loop>
<source src="https://www.bensound.com/bensound-music/bensound-romantic.mp3" type="audio/mpeg">
<source src="https://www.bensound.com/bensound-music/bensound-sweet.mp3" type="audio/mpeg">
</audio>
<button id="musicToggle" class="music-control" title="Toggle Music">
π΅
</button>
<script>
document.addEventListener('DOMContentLoaded', function() {
const heartsContainer = document.getElementById('heartsContainer');
const musicToggle = document.getElementById('musicToggle');
const romanticMusic = document.getElementById('romanticMusic');
const scrollToTop = document.getElementById('scrollToTop');
const scrollUpArrow = document.getElementById('scrollUpArrow');
const scrollIndicator = document.querySelector('.scroll-indicator');
let isPlaying = false;
// --- OPTIMIZED SCROLL HANDLER ---
// We use 'passive: true' to tell the browser this event won't cancel scrolling
window.addEventListener('scroll', function() {
const scrollPosition = window.scrollY;
const windowHeight = window.innerHeight;
// Use requestAnimationFrame for UI updates to prevent stutter
requestAnimationFrame(() => {
// Hide/show scroll indicator
if (scrollPosition > 100) {
scrollIndicator.classList.add('hidden');
} else {
scrollIndicator.classList.remove('hidden');
}
// Show/hide scroll to top buttons
if (scrollPosition > windowHeight / 2) {
scrollToTop.classList.add('visible');
scrollUpArrow.classList.add('visible');
} else {
scrollToTop.classList.remove('visible');
scrollUpArrow.classList.remove('visible');
}
});
}, { passive: true });
// --- NATIVE SMOOTH SCROLLING ---
function scrollToTopFunc(e) {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
function scrollDownFunc(e) {
e.preventDefault();
window.scrollTo({
top: window.innerHeight,
behavior: 'smooth'
});
}
scrollToTop.addEventListener('click', scrollToTopFunc);
scrollUpArrow.addEventListener('click', scrollToTopFunc);
scrollIndicator.addEventListener('click', scrollDownFunc);
// --- LIGHTWEIGHT FLOATING HEARTS ---
function createHeart() {
// Limit number of hearts on screen to prevent lag
if (heartsContainer.children.length > 15) return;
const heart = document.createElement('div');
heart.className = 'heart';
heart.innerHTML = ['β€οΈ', 'π', 'π'][Math.floor(Math.random() * 3)];
// Random positioning
const leftPos = Math.random() * 100;
const duration = Math.random() * 5 + 10; // Slower = less CPU usage
heart.style.cssText = `
left: ${leftPos}%;
animation-duration: ${duration}s;
font-size: ${Math.random() * 15 + 15}px;
opacity: ${Math.random() * 0.5 + 0.3};
`;
heartsContainer.appendChild(heart);
// Cleanup
setTimeout(() => {
if (heart.parentNode) heart.remove();
}, duration * 1000);
}
// Start hearts with lower frequency
createHeart();
setInterval(createHeart, 2000);
// --- MUSIC CONTROL (Unchanged) ---
musicToggle.addEventListener('click', function() {
if (isPlaying) {
romanticMusic.pause();
musicToggle.textContent = 'π΅';
musicToggle.style.opacity = '0.7';
} else {
romanticMusic.play().then(() => {
musicToggle.textContent = 'π';
musicToggle.style.opacity = '1';
isPlaying = true;
}).catch(() => {
musicToggle.textContent = 'π΅';
musicToggle.style.opacity = '0.7';
});
}
isPlaying = !isPlaying;
});
// Try autoplay
romanticMusic.volume = 0.3;
romanticMusic.play().then(() => {
musicToggle.textContent = 'π';
musicToggle.style.opacity = '1';
isPlaying = true;
}).catch(() => {
// Autoplay blocked (normal browser behavior)
});
// --- OPTIMIZED CELEBRATION BURST ---
// Reduced particle count for performance
setTimeout(() => {
const colors = ['#ff6b9d', '#e91e63'];
for (let i = 0; i < 10; i++) {
setTimeout(() => {
const particle = document.createElement('div');
particle.style.cssText = `
position: fixed;
left: 50%;
top: 50%;
width: 8px;
height: 8px;
background: ${colors[i % 2]};
border-radius: 50%;
pointer-events: none;
z-index: 9999;
transform: translate(-50%, -50%);
transition: all 1s ease-out;
will-change: transform, opacity;
`;
document.body.appendChild(particle);
// Force reflow
void particle.offsetWidth;
// Animate
const angle = Math.random() * Math.PI * 2;
const distance = 100 + Math.random() * 50;
particle.style.transform = `translate(calc(-50% + ${Math.cos(angle) * distance}px), calc(-50% + ${Math.sin(angle) * distance}px)) scale(0)`;
particle.style.opacity = '0';
setTimeout(() => {
if (particle.parentNode) particle.remove();
}, 1000);
}, i * 100);
}
}, 500);
// --- CLEANUP ---
// Simple click heart effect (optional, keep minimal)
document.addEventListener('click', function(e) {
// Ignore clicks on buttons
if (e.target.tagName === 'BUTTON' || e.target.closest('button')) return;
const heart = document.createElement('div');
heart.innerHTML = 'π';
heart.style.cssText = `
position: fixed;
left: ${e.clientX}px;
top: ${e.clientY}px;
font-size: 20px;
pointer-events: none;
z-index: 9999;
transform: translate(-50%, -50%);
transition: all 0.8s ease-out;
will-change: transform, opacity;
`;
document.body.appendChild(heart);
requestAnimationFrame(() => {
heart.style.transform = 'translate(-50%, -100px) scale(0.5)';
heart.style.opacity = '0';
});
setTimeout(() => {
if (heart.parentNode) heart.remove();
}, 800);
});
});
</script>
</body>
</html>