-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
32 lines (28 loc) · 929 Bytes
/
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
let taskbar = document.getElementsByClassName("taskbar")[0];
let startmenu = document.getElementsByClassName("startmenu")[0];
// Function to toggle the start menu
taskbar.addEventListener("click", () => {
if (startmenu.style.bottom == "50px") {
closeStartMenu();
} else {
openStartMenu();
}
});
// Function to open the start menu
function openStartMenu() {
startmenu.style.bottom = "50px";
startmenu.style.opacity = "1";
taskbar.classList.add("active");
}
// Function to close the start menu
function closeStartMenu() {
startmenu.style.bottom = "-655px";
startmenu.style.opacity = "0";
taskbar.classList.remove("active");
}
// Close start menu if user clicks outside of it
document.addEventListener("click", (event) => {
if (!taskbar.contains(event.target) && !startmenu.contains(event.target)) {
closeStartMenu();
}
});