diff --git a/components/header.js b/components/header.js index b136a91..0fc3a40 100644 --- a/components/header.js +++ b/components/header.js @@ -37,13 +37,20 @@ export class Header extends HTMLElement { this.menuPanel.appendChild(this.menu) this.shadowRoot.appendChild(this.menuPanel) this.overlay.addEventListener('click', () => { - this.overlay.classList.add('closing') - this.overlay.classList.remove('open') - this.menuPanel.classList.remove('open') - setTimeout(() => { - this.overlay.classList.remove('closing') - }, 250) + this.close() }) + this.menu.addEventListener('close', () => { + this.close() + }) + } + + close() { + this.overlay.classList.add('closing') + this.overlay.classList.remove('open') + this.menuPanel.classList.remove('open') + setTimeout(() => { + this.overlay.classList.remove('closing') + }, 250) } connectedCallback() {