-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquickLinksMenu.js
45 lines (37 loc) · 1.21 KB
/
quickLinksMenu.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
// Current menu state.
var menuOpened = false;
// Is menu currently animating to open/close. Used to disable further clicks when animating.
var menuAnimationRunning = false;
// Button and Menu elements.
var quickLinksButton = document.getElementsByClassName("qlmenu-menubutton")[0];
var quickLinksMenu = document.getElementsByClassName("qlmenu")[0];
var quickLinksMenuBackground = document.getElementsByClassName("qlmenu-background")[0];
quickLinksButton.onclick = function() {
if (!menuAnimationRunning) {
menuAnimationRunning = true;
if (menuOpened) {
console.log("FadeOut");
setTimeout(fadeOutComplete, 500);
quickLinksMenu.style.opacity = 0;
} else {
console.log("FadeIn");
quickLinksMenu.style.opacity = 0;
quickLinksMenu.classList.remove("qlmenu-hide");
setTimeout(fadeInStart, 50);
}
}
};
quickLinksMenuBackground.onclick = quickLinksButton.onclick();
function fadeOutComplete() {
quickLinksMenu.classList.add("qlmenu-hide");
menuOpened = false;
menuAnimationRunning = false;
}
function fadeInStart() {
quickLinksMenu.style.opacity = 1;
setTimeout(fadeInComplete, 500);
}
function fadeInComplete() {
menuOpened = true;
menuAnimationRunning = false;
}