Skip to content

Commit

Permalink
Fix for sticky menu close (#1171)
Browse files Browse the repository at this point in the history
* Fix for sticky menu close
  • Loading branch information
tyleralsbury authored Jan 14, 2022
1 parent 0ff4dae commit ee22e30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,10 @@ input[type='checkbox'] {
transform: translateY(-100%);
}

.shopify-section-header-hidden.menu-open {
transform: translateY(0);
}

#shopify-section-header.animate {
transition: transform 0.15s ease-out;
}
Expand Down
6 changes: 6 additions & 0 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ class HeaderDrawer extends MenuDrawer {
this.header = this.header || document.getElementById('shopify-section-header');
this.borderOffset = this.borderOffset || this.closest('.header-wrapper').classList.contains('header-wrapper--border-bottom') ? 1 : 0;
document.documentElement.style.setProperty('--header-bottom-position', `${parseInt(this.header.getBoundingClientRect().bottom - this.borderOffset)}px`);
this.header.classList.add('menu-open');

setTimeout(() => {
this.mainDetailsToggle.classList.add('menu-opening');
Expand All @@ -417,6 +418,11 @@ class HeaderDrawer extends MenuDrawer {
trapFocus(this.mainDetailsToggle, summaryElement);
document.body.classList.add(`overflow-hidden-${this.dataset.breakpoint}`);
}

closeMenuDrawer(event, elementToFocus) {
super.closeMenuDrawer(event, elementToFocus);
this.header.classList.remove('menu-open');
}
}

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

0 comments on commit ee22e30

Please sign in to comment.