Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
161 lines (128 loc) · 4.4 KB
/
Copy pathscript.js
File metadata and controls
161 lines (128 loc) · 4.4 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
const noBtn = document.getElementById("noBtn");
const yesBtn = document.getElementById("yesBtn");
const heading = document.getElementById("heading");
const dramaticSound = document.getElementById("dramaticSound");
const laughSound = document.getElementById("laughSound");
let isFloating = false;
let clickCount = 0;
const messages = [
"really?",
"are you sure?",
"cmon be for real 😭",
"be serious right now",
"why you playing like that",
"stopppp",
"don’t do this to me 💔",
"pwease 🥺👉👈",
"you know you want to 😏",
"just click yes already ❤️"
];
// Keep text spaced above growing button
function updateSpacing() {
const yesScale = 1 + clickCount * 0.25;
const extraSpace = yesScale * 20;
heading.style.marginBottom = 30 + extraSpace + "px";
}
// Smooth avoidance
document.addEventListener("mousemove", (e) => {
if (!noBtn || !noBtn.isConnected) return;
const rect = noBtn.getBoundingClientRect();
const btnCenterX = rect.left + rect.width / 2;
const btnCenterY = rect.top + rect.height / 2;
const dx = btnCenterX - e.clientX;
const dy = btnCenterY - e.clientY;
const distance = Math.hypot(dx, dy);
const safeDistance = 140;
if (distance < safeDistance) {
if (!isFloating) {
noBtn.style.position = "fixed";
noBtn.style.left = rect.left + "px";
noBtn.style.top = rect.top + "px";
isFloating = true;
}
const angle = Math.atan2(dy, dx);
const moveDistance = 120;
let newX = rect.left + Math.cos(angle) * moveDistance;
let newY = rect.top + Math.sin(angle) * moveDistance;
const maxX = window.innerWidth - rect.width;
const maxY = window.innerHeight - rect.height;
newX = Math.max(0, Math.min(maxX, newX));
newY = Math.max(0, Math.min(maxY, newY));
noBtn.style.left = newX + "px";
noBtn.style.top = newY + "px";
}
});
// Teleport on hover
noBtn.addEventListener("mouseenter", () => {
const rect = noBtn.getBoundingClientRect();
const maxX = window.innerWidth - rect.width;
const maxY = window.innerHeight - rect.height;
noBtn.style.position = "fixed";
noBtn.style.left = Math.random() * maxX + "px";
noBtn.style.top = Math.random() * maxY + "px";
isFloating = true;
});
// No button click escalation
noBtn.addEventListener("click", (e) => {
e.preventDefault();
if (clickCount < messages.length) {
heading.textContent = messages[clickCount];
}
clickCount++;
// Grow Yes
let yesScale = 1 + clickCount * 0.25;
yesBtn.style.transform = `scale(${yesScale})`;
// Shrink No
let noScale = 1 - clickCount * 0.1;
if (noScale < 0.15) noScale = 0.15;
noBtn.style.transform = `scale(${noScale})`;
updateSpacing();
// FINAL REMOVAL
if (clickCount >= messages.length) {
dramaticSound.play();
setTimeout(() => {
laughSound.play();
}, 1500);
noBtn.style.transition = "all 0.5s ease";
noBtn.style.transform = "scale(0)";
setTimeout(() => {
noBtn.remove();
}, 500);
}
});
// YES button wins
yesBtn.addEventListener("click", () => {
// Remove buttons and old heading
const mainBox = document.getElementById("mainBox");
mainBox.innerHTML = `
<div class="final-screen">
<h1 id="finalMessage">You have great taste in men 😉❤️</h1>
</div>
`;
// Make the final-screen take full viewport
mainBox.style.width = "100%";
mainBox.style.height = "100vh";
mainBox.style.display = "flex";
mainBox.style.justifyContent = "center";
mainBox.style.alignItems = "center";
mainBox.style.background = "transparent"; // don't override body gradient
mainBox.style.boxShadow = "none";
mainBox.style.borderRadius = "0";
mainBox.style.padding = "0";
startHeartRain();
});
// HEART RAIN FUNCTION
function startHeartRain() {
setInterval(() => {
const heart = document.createElement("div");
heart.classList.add("heart");
heart.textContent = "❤️";
heart.style.left = Math.random() * 100 + "vw";
heart.style.animationDuration = (Math.random() * 2 + 3) + "s";
heart.style.fontSize = (Math.random() * 20 + 20) + "px";
document.body.appendChild(heart);
setTimeout(() => {
heart.remove();
}, 5000);
}, 200);
}