-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (30 loc) · 1 KB
/
script.js
File metadata and controls
37 lines (30 loc) · 1 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
// Typing animation
function typeText(element, text, delay = 100, callback = null) {
element.textContent = "";
let i = 0;
function type() {
if (i < text.length) {
element.textContent += text.charAt(i);
i++;
setTimeout(type, delay);
} else if (callback) {
callback();
}
}
type();
}
document.addEventListener("DOMContentLoaded", () => {
const playButton = document.getElementById("playButton");
const contentContainer = document.querySelector(".content-container");
const askToPlayMessage = document.getElementById("askToPlayMessage");
// Play button on click action
const playButton_OnClick = () => {
window.open("./Games/birthday_message/", "_self");
}
typeText(askToPlayMessage, "Do you want to play a game with me?", 70, () => {
setTimeout(() => {
playButton.style.opacity = "1";
}, 700);
});
playButton.addEventListener("click", playButton_OnClick);
});