-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
51 lines (45 loc) · 1.46 KB
/
Copy pathscript.js
File metadata and controls
51 lines (45 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
const enterScreen = document.getElementById('enter-screen');
const enterBtn = document.getElementById('enter-btn');
const mainWrapper = document.getElementById('main-wrapper');
const audio = document.getElementById('bg-audio');
const audioToggle = document.getElementById('audio-toggle');
const iconVolume = audioToggle.querySelector('.icon-volume');
const iconMute = audioToggle.querySelector('.icon-mute');
const video = document.getElementById('bg-video');
let audioPlaying = false;
function enterSite() {
enterScreen.classList.add('hidden');
mainWrapper.classList.add('visible');
audio.volume = 0.35;
audio.play().then(() => {
audioPlaying = true;
audioToggle.classList.add('playing');
iconVolume.classList.remove('hidden');
iconMute.classList.add('hidden');
}).catch(() => {
audioPlaying = false;
audioToggle.classList.remove('playing');
iconVolume.classList.add('hidden');
iconMute.classList.remove('hidden');
});
if (video.paused) {
video.play().catch(() => {});
}
}
enterBtn.addEventListener('click', enterSite);
audioToggle.addEventListener('click', () => {
if (audioPlaying) {
audio.pause();
audioPlaying = false;
audioToggle.classList.remove('playing');
iconVolume.classList.add('hidden');
iconMute.classList.remove('hidden');
} else {
audio.play().then(() => {
audioPlaying = true;
audioToggle.classList.add('playing');
iconVolume.classList.remove('hidden');
iconMute.classList.add('hidden');
}).catch(() => {});
}
});