-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
39 lines (35 loc) · 1.39 KB
/
scripts.js
File metadata and controls
39 lines (35 loc) · 1.39 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
const toggleBtn = document.getElementById('toggleVideoBtn');
const seizureVideoLeft = document.getElementById('seizureVideoLeft');
const seizureVideoRight = document.getElementById('seizureVideoRight');
const avatar = document.querySelector('.avatar');
const heading = document.querySelector('h1');
const subtext = document.querySelector('p');
let isPlaying = false;
function isMobile() {
return window.innerWidth <= 600;
}
toggleBtn.addEventListener('click', async () => {
if (!isPlaying) {
seizureVideoLeft.style.display = 'block';
seizureVideoRight.style.display = 'block';
seizureVideoLeft.currentTime = 0;
seizureVideoRight.currentTime = 0;
await Promise.all([seizureVideoLeft.play(), seizureVideoRight.play()]);
toggleBtn.textContent = 'MAKE IT STOP';
heading.textContent = 'Good morning';
subtext.textContent = 'Long time no see!';
if (isMobile()) {
avatar.classList.add('hide-avatar-mobile');
}
} else {
seizureVideoLeft.pause();
seizureVideoRight.pause();
seizureVideoLeft.style.display = 'none';
seizureVideoRight.style.display = 'none';
toggleBtn.textContent = 'SEIZURE ALERT';
heading.textContent = 'Ohayo!';
subtext.textContent = 'Hisashiburi dana';
avatar.classList.remove('hide-avatar-mobile');
}
isPlaying = !isPlaying;
});