Jump to content

Fixed Parity Deals Banner When Scrolling

Recommended Posts

How do I make this Parity Deals banner appear and scroll with my fixed navigation?

Right now my navigation seems to be covering the parity deals banner.
 

<!-- Start of Parity Deals Banner -->
<script>
function debounceCustom(func, timeout =300) 
{
let timer=null;
  return (...args) => {clearTimeout(timer);
    timer = setTimeout(() => { func.apply(this, args); }, timeout);
  };
}
function fixHeader() {
  window.scrollY;
  const findBanner = document.getElementsByClassName('parity-banner-has-logo');
  const findMenu = document.getElementsByClassName('header-announcement-bar-wrapper');
  if (findBanner.length > 0 && findMenu.length > 0) {
    const banner = findBanner[0];
    const menu = findMenu[0];
    banner.style.zIndex = 100;
    if (window.scrollY === 0) {
      menu.style.marginTop = banner.offsetHeight.toString() + 'px';
    } else {
      menu.style.marginTop = '0px';
    }
  }
}
document.addEventListener('scroll', debounceCustom(fixHeader), { passive: true });
fixHeader();
</script>
<!-- End of Parity Deals Banner -->

 

Link to comment
  • Replies 3
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.