-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupaNav.js
55 lines (48 loc) · 1.71 KB
/
supaNav.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
/********************************************
* Toggles the menu by adding or removing
* relative class
********************************************/
function toggleMenu() {
var pageI = document.getElementById("page");
if (pageI.classList.contains("menu-open"))
{
// Menu is open close it
pageI.classList.remove("menu-open");
pageI.classList.add("menu-close");
enableBodyScroll();
} else {
// Menu is closed open it
pageI.classList.remove("menu-close");
pageI.classList.add("menu-open");
disableBodyScroll();
}
pageI.addEventListener("webkitTransitionEnd", resetAnimations, false);
pageI.addEventListener("msTransitionEnd", resetAnimations, false);
pageI.addEventListener("oTransitionEnd", resetAnimations, false);
pageI.addEventListener("transitionEnd", resetAnimations, false);
}
/********************************************
* Resets animations after close
* animation is finished
* Note: Fixes horizontal scrolling after
* close animation
********************************************/
function resetAnimations() {
// Reset animations
if (document.getElementById("page").classList.contains("menu-close"))
document.getElementById("page").classList.remove("menu-close");
}
/********************************************
* Disables scrolling when menu is open
********************************************/
function disableBodyScroll() {
document.body.style.overflow = "hidden";
document.getElementById("page").style.overflow = "hidden";
}
/********************************************
* Enables scrolling when menu is closed
********************************************/
function enableBodyScroll() {
document.body.style.overflow = "";
document.getElementById("page").style.overflow = "";
}