-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (43 loc) · 1.13 KB
/
script.js
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
//IIFE
(function () {
"use strict";
var menuId;
function init () {
menuId = document.getElementById("menu");
document.addEventListener("scroll",scrollMenu,false);
}
function scrollMenu () {
if (document.documentElement.scrollTop > 50) {
menuId.classList.add("scroll");
console.log('scroll');
}
else {
menuId.classList.remove("scroll");
console.log('no-scroll');
}
}
document.addEventListener("DOMContentLoaded",init,false);
})();
(function (){
"use strict";
var mobBtn, topMenu;
function init() {
mobBtn = document.getElementById("mobile-btn");
topMenu = document.getElementById("top-menu");
mobBtn.addEventListener("click",mobileMenu,false);
}
function mobileMenu() {
if(topMenu.classList.contains("mobile-open")) {
topMenu.classList.remove("mobile-open");
}else{
topMenu.classList.add("mobile-open");
}
if (mobBtn.classList.contains("hamburger-cross")) {
mobBtn.classList.remove("hamburger-cross");
}
else {
mobBtn.classList.add("hamburger-cross");
}
}
document.addEventListener("DOMContentLoaded",init);
})();