-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo_you_love_me.js
More file actions
28 lines (23 loc) · 992 Bytes
/
Copy pathdo_you_love_me.js
File metadata and controls
28 lines (23 loc) · 992 Bytes
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
const questionContainer = document.querySelector(".question-container");
const resultContainer = document.querySelector(".result-container.yes");
const gifResult = document.querySelector(".gif-result");
const heartLoader = document.querySelector(".cssload-main");
const yesBtn = document.querySelector(".js-yes-btn");
const noBtn = document.querySelector(".js-no-btn");
// /change the postion of no button
noBtn.addEventListener("mouseover", () => {
const newX = Math.floor(Math.random() * questionContainer.offsetWidth);
const newY = Math.floor(Math.random() * questionContainer.offsetWidth);
noBtn.style.left = `${newX}px`;
noBtn.style.top = `${newY}px`;
});
// yes button functionality
yesBtn.addEventListener("click", () => {
questionContainer.style.display = "none";
heartLoader.style.display = "inherit";
const timeoutId = setTimeout(() => {
heartLoader.style.display = "none";
resultContainer.style.display = "inherit";
gifResult.play();
}, 3000);
});