-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.js
More file actions
84 lines (70 loc) · 2.4 KB
/
header.js
File metadata and controls
84 lines (70 loc) · 2.4 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
$(".gnb-list").on("mouseover", function () {
document.querySelector(".subCover").classList.add("down");
document.querySelector(".black-bg").classList.add("show");
document.querySelector(".black-bg").style.height = "100%";
document.querySelector(".gnb").style.height = "630px";
});
$(".gnb-list").on("mouseleave", function () {
document.querySelector(".subCover").classList.remove("down");
document.querySelectorAll(".sub-gnb").forEach((e) => {
document.querySelector(".black-bg").classList.remove("show");
});
document.querySelector(".black-bg").style.height = "0";
document.querySelector(".gnb").style.height = "130px";
});
$("#menu-btn").on("click", function () {
$(".gnb-list").addClass("menuOn");
$("#menu-btn").hide();
$("#close-btn").addClass("show");
});
$("#close-btn").on("click", function () {
$(".gnb-list").removeClass("menuOn");
$("#close-btn").removeClass("show");
$("#menu-btn").show();
document.querySelectorAll(".sub-gnb").forEach((e) => {
e.classList.remove("open");
});
});
const contentList = document.querySelector(".gnb-list");
const content = document.querySelectorAll(".title-menu");
const gnbBody = document.querySelectorAll(".sub-gnb");
contentList.addEventListener("click", (e) => {
let isActive = e.target.parentNode.classList.contains("active");
if (isActive) {
e.target.parentNode.classList.remove("active");
e.target.parentNode.childNodes.forEach((ele) => {
if (ele.tagName === "UL") {
ele.classList.remove("open");
}
});
} else {
content.forEach((ele) => {
ele.classList.remove("active");
});
e.target.parentNode.classList.add("active");
gnbBody.forEach((ele) => {
ele.classList.remove("open");
});
let index = e.target.parentNode.dataset.num;
gnbBody[index].classList.add("open");
}
});
(function(window, document){
'use strict';
const $gnbList = document.querySelectorAll('.gnb-list'); // NodeList
const $menuBtn = document.getElementById('menu-btn');
window.addEventListener('resize', function() {
// console.log(window.innerWidth)
if (window.innerWidth > 1024) {
offElements();
}
});
function offElements() {
// console.log('offElements');
[].forEach.call($gnbList, function(toggle) {
toggle.classList.remove('menuOn');
$("#close-btn").removeClass("show");
$("#menu-btn").show();
});
}
})(window, document)