Skip to content

Commit

Permalink
Clean up JS logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenekasimov committed Jan 12, 2023
1 parent 033cd80 commit 60b86d3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class MenuDrawer extends HTMLElement {
this.closeAnimation(this.mainDetailsToggle);
}

onFocusOut(event) {
onFocusOut() {
setTimeout(() => {
if (this.mainDetailsToggle.hasAttribute('open') && !this.mainDetailsToggle.contains(document.activeElement)) this.closeMenuDrawer();
});
Expand Down Expand Up @@ -417,11 +417,6 @@ customElements.define('menu-drawer', MenuDrawer);
class HeaderDrawer extends MenuDrawer {
constructor() {
super();

this.onResize = () => {
document.documentElement.style.setProperty('--header-bottom-position', `${parseInt(this.header.getBoundingClientRect().bottom - this.borderOffset)}px`);
document.documentElement.style.setProperty('--viewport-height', `${window.innerHeight}px`);
};
}

openMenuDrawer(summaryElement) {
Expand All @@ -442,12 +437,17 @@ class HeaderDrawer extends MenuDrawer {
}

closeMenuDrawer(event, elementToFocus) {
if (!elementToFocus) return;
super.closeMenuDrawer(event, elementToFocus);
console.log(elementToFocus);
this.header.classList.remove('menu-open');
elementToFocus.classList.remove(`drawer-open`);
window.removeEventListener('resize', this.onResize);
}

onResize = () => {
this.header && document.documentElement.style.setProperty('--header-bottom-position', `${parseInt(this.header.getBoundingClientRect().bottom - this.borderOffset)}px`);
document.documentElement.style.setProperty('--viewport-height', `${window.innerHeight}px`);
};
}

customElements.define('header-drawer', HeaderDrawer);
Expand Down

0 comments on commit 60b86d3

Please sign in to comment.