-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
63 lines (50 loc) · 2.28 KB
/
script.js
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
// Get the "No" button element
const noButton = document.getElementById("no-button");
// Add a mouseover event listener to move the "No" button randomly
noButton.addEventListener("mouseover", () => {
const x = Math.floor(Math.random() * window.innerWidth);
const y = Math.floor(Math.random() * window.innerHeight);
// Restrict the "No" button's movement within the bounds of the screen
const buttonWidth = noButton.offsetWidth;
const buttonHeight = noButton.offsetHeight;
const maxX = window.innerWidth - buttonWidth;
const maxY = window.innerHeight - buttonHeight;
const adjustedX = x < maxX ? x : maxX;
const adjustedY = y < maxY ? y : maxY;
// Apply the new position to the button
noButton.style.position = "absolute";
noButton.style.left = `${adjustedX}px`;
noButton.style.top = `${adjustedY}px`;
});
// Get the "Yes" button element
const yesButton = document.getElementById("yes-button");
// Add a click event listener to create confetti
yesButton.addEventListener("click", () => {
var confettiElement = document.getElementById('confetti-canvas');
var confettiSettings = { target: confettiElement, max: 729, size: 1, animate: true, props: ['circle', 'square', 'triangle', 'line'], colors: [[165,104,246],[230,61,135],[0,199,228],[253,214,126]], clock: 25, rotate: true,start_from_edge: true, respawn: true };
yesButton.style.display = "none";
noButton.style.display = "none";
var gif = document.getElementById("gif");
var header = document.getElementById("main");
header.style.display = "none";
gif.style.display = "none";
//change the style of the confetti canvas
confettiElement.style.position = "absolute";
confettiElement.style.top = "0";
confettiElement.style.left = "0";
confettiElement.style.width = "100%";
confettiElement.style.height = "100%";
confettiElement.style.zIndex = "1000";
var confetti = new ConfettiGenerator(confettiSettings);
confetti.render();
let p = document.createElement("p");
p.innerText = "Ill be waiting 🎀 \nCall me once you go home😘";
p.style.fontSize = "2rem";
p.style.fontWeight = "bold";
p.style.textAlign = "center";
p.style.position = "absolute";
p.style.top = "50%";
p.style.left = "50%";
p.style.transform = "translate(-50%, -50%)";
document.body.appendChild(p);
});