-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (36 loc) · 1.31 KB
/
script.js
File metadata and controls
41 lines (36 loc) · 1.31 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
const backgroundMusic = document.getElementById("background-music");
const musicToggle = document.getElementById("music-toggle");
let isPlaying = false;
let firstClick = false;
// Play music on first click anywhere on the page
document.addEventListener("click", () => {
if (!firstClick) {
backgroundMusic.play();
isPlaying = true;
firstClick = true;
}
});
// Toggle music on/off when the music icon is clicked
musicToggle.addEventListener("click", (e) => {
e.stopPropagation(); // Prevent triggering the first click handler
if (isPlaying) {
backgroundMusic.pause();
musicToggle.classList.remove("playing");
} else {
backgroundMusic.play();
musicToggle.classList.add("playing");
}
isPlaying = !isPlaying;
});
document.addEventListener('DOMContentLoaded', function () {
const letter = document.getElementById('hogwarts-letter');
const splashScreen = document.getElementById('splash-screen');
const mainContent = document.getElementById('main-content');
letter.addEventListener('click', function () {
letter.style.animation = 'zoomOut 1s forwards';
setTimeout(function () {
splashScreen.style.display = 'none';
mainContent.style.display = 'block';
}, 1000); // Wait for the animation to finish
});
});