[Resolved] Secondary Navigation Tweaks

Home Forums Support [Resolved] Secondary Navigation Tweaks

Home Forums Support Secondary Navigation Tweaks

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #800412
    Vish

    Hello πŸ™‚

    How to:

    1. Display the Secondary Navigation at display at the bottom of the screen (not page).
    2. How to make it sticky only while scrolling up?

    Thank you!

    #800529
    David
    Staff
    Customer Support

    Hi there,

    this CSS:

    #secondary-navigation {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }
    #secondary-navigation.is-visible {
    	opacity: 1;
    }
    #secondary-navigation.is-hidden {
    	opacity: 0;
    	pointer-events: none;
    }
    body {
        margin-bottom: 60px; /* height of secondary nav */
    }

    And this Javascript:

    <script type = "text/javascript">
    
    let scrollPos = 0;
    const nav = document.querySelector('.secondary-navigation');
    
    function checkPosition() {
        let windowY = window.scrollY;
        if (windowY < scrollPos) {
            // Scrolling UP
            nav.classList.add('is-visible');
            nav.classList.remove('is-hidden');
        } else {
            // Scrolling DOWN
            nav.classList.add('is-hidden');
            nav.classList.remove('is-visible');
        }
        scrollPos = windowY;
    }
    
    window.addEventListener('scroll', checkPosition);
    
    </script>
    #800616
    Vish

    Thanks, David. While the above CSS did move the secondary navigation to the bottom, it did not achieve the point I mentioned.

    2. How to make it sticky only while scrolling up?

    I just want it to appear only while the user is scrolling up and not while scrolling down. πŸ™‚

    #800920
    David
    Staff
    Customer Support

    Requires some more CSS and some Javascript – edited code here

    #801323
    Vish

    Thanks, David. You are a star! πŸ™‚

    #801335
    David
    Staff
    Customer Support

    You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.