-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
46 lines (38 loc) · 1.36 KB
/
index.js
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
const soundCloud = document.querySelector('.sound-cloud');
const off = document.querySelector('#off');
const on = document.querySelector('#on');
const myAudio = document.querySelector('#myAudio');
off.addEventListener('click', () => soundTrack('off'));
on.addEventListener('click', () => soundTrack('on'));
const soundTrack = (soundState) => {
if(soundState === 'off'){
on.style.display = 'block';
off.style.display = 'none';
soundCloud.style.color = "#08fdd8";
myAudio.play();
}
else if(soundState === 'on'){
on.style.display = 'none';
off.style.display = 'block';
soundCloud.style.color = "#f50057";
myAudio.pause();
}
}
// Play music functionality
const btnBars = document.querySelector('.bars');
const btnTimes = document.querySelector('.times');
const SideNav = document.querySelector('.aside');
btnBars.addEventListener('click', () => myFunc('open'));
btnTimes.addEventListener('click', () => myFunc('close'));
const myFunc = (navCondition) => {
if(navCondition === 'open'){
SideNav.classList.add('show-nav');
btnTimes.style.display = "block";
btnBars.style.display = "none";
}
else if(navCondition === 'close'){
SideNav.classList.remove('show-nav');
btnTimes.style.display = "none";
btnBars.style.display = "block";
}
}