-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (32 loc) · 1.03 KB
/
script.js
File metadata and controls
37 lines (32 loc) · 1.03 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
const noWrapper = document.getElementById("noWrapper");
const card = document.querySelector(".card");
const yesBtn = document.getElementById("yes");
// move NO wrapper on hover
noWrapper.addEventListener("mouseenter", moveNo);
noWrapper.addEventListener("touchstart", moveNo); // mobile support
function moveNo() {
const maxX = card.clientWidth - noWrapper.offsetWidth - 20;
const maxY = card.clientHeight - noWrapper.offsetHeight - 20;
const randomX = Math.random() * maxX;
const randomY = Math.random() * maxY;
noWrapper.style.left = randomX + "px";
noWrapper.style.top = randomY + "px";
}
// YES button action
yesBtn.addEventListener("click", () => {
document.body.innerHTML = `
<div style="
height:100vh;
display:flex;
justify-content:center;
align-items:center;
background:#f4b6c2;
font-family:Segoe UI, Arial;
text-align:center;
">
<h1 style="font-size:36px;color:#e63946;">
I knew it 😘💖
</h1>
</div>
`;
});