-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
60 lines (46 loc) · 1.71 KB
/
script.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
46
47
48
49
50
51
52
53
54
55
56
57
// rotate Hamburger menu and show menu
const menuButton = document.querySelector('.nav--menu-button');
const headerMenu = document.querySelector('.header--menu');
const aboutSection = document.getElementById('about');
const projectSection = document.getElementById('project');
const aboutLink = document.getElementById('aboutLink');
const projectLink = document.getElementById('projectLink');
function toggleActive() {
menuButton.classList.toggle('active');
headerMenu.classList.toggle('active');
aboutSection.classList.toggle('active');
projectSection.classList.toggle('active');
}
function switchProject() {
if (projectSection.classList.contains('active')) {
if (projectSection.classList.contains('second')) {
aboutSection.classList.toggle('first');
aboutSection.classList.add('second');
projectSection.classList.toggle('second');
projectSection.classList.add('first');
}
toggleActive();
}
}
function switchAbout() {
if (aboutSection.classList.contains('active')) {
if (aboutSection.classList.contains('second')) {
projectSection.classList.toggle('first');
projectSection.classList.add('second');
aboutSection.classList.toggle('second');
aboutSection.classList.add('first');
}
toggleActive();
}
}
menuButton.addEventListener('click', toggleActive);
aboutSection.addEventListener('click', switchAbout);
projectSection.addEventListener('click', switchProject);
aboutLink.addEventListener('click', (event) => {
event.preventDefault();
switchAbout();
})
projectLink.addEventListener('click', (event) => {
event.preventDefault();
switchProject();
})