v0.1.2 헤더 구조 및 사이드바 효과 수정
This commit is contained in:
@@ -19,10 +19,49 @@
|
||||
});
|
||||
});
|
||||
|
||||
function syncAccordion(section, open) {
|
||||
var button = section.querySelector("[data-accordion]");
|
||||
var content = section.querySelector("[data-accordion-content]");
|
||||
|
||||
section.classList.toggle("is-open", open);
|
||||
|
||||
if (button) {
|
||||
button.setAttribute("aria-expanded", open ? "true" : "false");
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (open) {
|
||||
content.style.height = content.scrollHeight + "px";
|
||||
window.setTimeout(function () {
|
||||
if (section.classList.contains("is-open")) {
|
||||
content.style.height = "auto";
|
||||
}
|
||||
}, 260);
|
||||
} else {
|
||||
content.style.height = content.scrollHeight + "px";
|
||||
window.requestAnimationFrame(function () {
|
||||
content.style.height = "0px";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll(".menu-group").forEach(function (section) {
|
||||
var content = section.querySelector("[data-accordion-content]");
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
|
||||
content.style.overflow = "hidden";
|
||||
content.style.height = section.classList.contains("is-open") ? "auto" : "0px";
|
||||
});
|
||||
|
||||
document.querySelectorAll("[data-accordion]").forEach(function (button) {
|
||||
button.addEventListener("click", function () {
|
||||
var section = button.parentElement;
|
||||
section.classList.toggle("is-open");
|
||||
syncAccordion(section, !section.classList.contains("is-open"));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user