Skip to content

Commit

Permalink
Merge pull request #2741 from Codeinwp/fix/cart-icon-opening-behaviou…
Browse files Browse the repository at this point in the history
…r-in-left-side-header-issue-2468

fix: Fix cart icon opening behaviour when positioned in the left side…
  • Loading branch information
selul authored Apr 23, 2021
2 parents 8e9a063 + 8298edc commit 8f68205
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions assets/js/src/frontend/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,17 @@ function handleSearch() {
* Handle the mini cart position in nav.
*/
function handleMiniCartPosition() {
const elem = document.querySelectorAll('.header--row .nv-nav-cart');
if (elem.length === 0) {
const item = document.querySelector('.header--row .menu-item-nav-cart');
if (item === null) {
return;
}
neveEach(elem, (item) => {
const bounding = item.getBoundingClientRect();
if (bounding.left < 0) {
item.style.left = 0;
}
});

const miniCart = item.querySelector('.nv-nav-cart');

if (miniCart !== null) {
miniCart.style.left =
item.getBoundingClientRect().left < 350 ? 0 : null;
}
}

window.addEventListener('resize', handleMiniCartPosition);
Expand Down

0 comments on commit 8f68205

Please sign in to comment.