• Hi Team,

    I am using Gneratepress’s child theme. I have enabled the sticky menu using the below CSS.

    @media (min-width: 769px) {
        .main-navigation {
            position: sticky;
            top: 0px;
            z-index: 99;
        }
    }

    Now I want to hide the sticky menu during scroll down. When user is scrolling up, that time I want to show the sticky menu.

    Please help me achieve this.

    • This topic was modified 3 years, 10 months ago by embetronicx.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi there,

    That option is available in our premium plugin and it’s not possible with CSS unfortunately:
    https://docs.generatepress.com/article/sticky-navigation/#hide-when-scrolling-down

    You will need to find a custom solution for it.

    Thread Starter embetronicx

    (@embetronicx)

    Thanks for your reply.

    Is there any custom code that I can put into functions.php?

    Hi,

    Thanks for your reply.

    Is there any custom code that I can put into functions.php?

    I’m afraid that’s out of our scope of support here.

    But to give you an idea:

    You’ll need a vanilla JavaScript or jQuery that toggles the visibility of the header when you scroll down.

    I believe you can find free scripts for this on the web but you’ll have to modify them a bit to work. ??

    • This reply was modified 3 years, 10 months ago by Elvin.
    Thread Starter embetronicx

    (@embetronicx)

    Thanks for the idea.

    Thanks for the idea.

    No problem. ??

    Thread Starter embetronicx

    (@embetronicx)

    Hi,

    I have added the below css for sticky menu.

    @media (min-width: 769px) {
        .main-navigation {
            position: fixed;
            top: 0px;
    	width:100%;
            z-index: 99;
        }
    }

    But it overlaps with the header (menu has to come after the header). Please check out the image attached.

    My aim is to enable the sticky menu. If I use position: sticky; it is just flickering when I add my JS for auto hide during scroll down. So I have changed this to position: fixed;. Now it is not flickering. But it is overlapping with the header. Can you help me to solve this?

    JS used:

    jQuery(document).ready(function( $ ){
      var previousScroll = 0;
      $(window).scroll(function(){
           var currentScroll = $(this).scrollTop();
           
           if (currentScroll >= previousScroll){
               $('#primary-menu').addClass('menu-toggle');
           } else {
               $('#primary-menu').removeClass('menu-toggle');
           }
           previousScroll = currentScroll;
        });
      
    });
    • This reply was modified 3 years, 10 months ago by embetronicx.

    Unfortunately we are not able to help with the custom solution in the free forum here – especially that this is an option in our premium plugin.

    You will need to try a forum like this:
    https://wordpress.stackexchange.com/

    Thanks for your understanding.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Disable Sticky Menu while scrolling down’ is closed to new replies.