main-header - sticky
This commit is contained in:
parent
220a6f4ada
commit
8a720f67dd
2 changed files with 19 additions and 5 deletions
|
|
@ -12,4 +12,16 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
// Listeners
|
||||
nodes.burgerBtn.addEventListener("click", () => expandNav(nodes));
|
||||
nodes.closeNavBtn.addEventListener("click", () => closeNav(nodes));
|
||||
|
||||
// Key shortcuts
|
||||
window.addEventListener("keyup", (event) => {
|
||||
if (event.key === "Escape") {
|
||||
closeNav(nodes);
|
||||
}
|
||||
});
|
||||
window.addEventListener("scroll", (event) => {
|
||||
if (nodes.expandedNav.classList.contains("open")) {
|
||||
closeNav(nodes);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue