Jump to content

How would I adjust Header transition timing?

Recommended Posts

I'm currently using a scrolling header option that transitions from transparent to a solid color when you begin scrolling (on version 7.1). How can I adjust the header transition timing so that the solid color doesn't arrive until the user hits the second section, if you will? 

For example, please see the pair of screenshots. The transparent header transitions to a black solid background almost immediately; I'd like it to transition to a black solid background at the transition between the hero and the Contact Us section. 

Screenshot 2024-02-22 at 11.04.01 AM.png

Screenshot 2024-02-22 at 11.04.13 AM.png

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

Top Posters In This Topic

  • 4 weeks later...

Try this code to Website > Website Tools > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(function(){
 var visibleTop = 800;
  $(window).scroll(function() {
    var scroll = getCurrentScroll();
      if ( scroll >= visibleTop ) {
           $('header#header').addClass('test-something');
        }
        else {
            $('header#header').removeClass('test-something');
        }
  });
function getCurrentScroll() {
    return window.pageYOffset || document.documentElement.scrollTop;
    }
});
</script>
<style>
  header#header {
    background-color: transparent !important;
}
header#header.test-something {
    background-color: #000 !important;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

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.