• Resolved austin113

    (@austin113)


    Hello,

    I am updating a site for my client. They wanted a menu below the actual menu to help with navigation on this specific page. I have made a second menu using the Mega Menu Plugin. This allowed me to add the second menu to just this specific page by using the accompanying Mega Menu Widget. My client wants this secondary menu to be a sticky menu and I have it sticking in one position the whole time via simple custom CSS code seen below:

    #buttons {
    position: fixed;
    top: 10;
    }

    Now I am trying to have the offset to be just below this second sticky menu. I have inspected the page to know this <div class=”mega-menu-toggle”> which according to the videos I have found I should be able to just plug in #mega-menu-toggle or .mega-menu-toggle into the offset box, but it doesn’t seem to work. I have tried a lot of different things to put into the offset box but nothing seems to work.

    Any advice to fix this issue would be greatly appreciated.

    Extra info: I am using SiteOrigin Page Builder if this means anything because it might.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author malihu

    (@malihu)

    Hello,

    The selector should be .mega-menu-toggle as the “mega-menu-toggle” is a class name. This said, I can’t really tell why the offset doesn’t work. Maybe the “mega-menu-toggle” element shouldn’t be the offset selector (what’s the height of the .mega-menu-toggle element?) or maybe some other mega menu script overwrites smooth scrolling.

    Try going into plugin settings and enable “Prevent other scripts from handling plugin’s links” option and see if it fixes the issue.

    If I could see your site/page I’d be able to check what happens and provide an exact solution (not sure if you can post or send me your URL).

    Thread Starter austin113

    (@austin113)

    Hello,

    I tried enabling “Prevent other scripts from handling plugin’s links” and it’s still the same. I can share the URL but is there a way to do it privately?

    I have been able to put in just a number for the offset and it gets it significantly closer, but it would be so much easier if we can get it to work based on the menu.

    Thank you!

    Plugin Author malihu

    (@malihu)

    Sure you can contact me here.

    Thread Starter austin113

    (@austin113)

    Fantastic! A message has been sent to you with the link.

    Plugin Author malihu

    (@malihu)

    I checked your page and the problem is that you have 2 independent sticky menus: 1)the standard site header nav menu and 2)the secondary mega menu. That’s why the single offset selector cannot work. You’ll need to compensate for both menus but those 2 menus are not within a single element, so there’s no way to calculate their height via a single selector. 

    The only way to do this is either add a fixed number of pixels (e.g. 400) or try adding an extra js script in your theme/child-theme header.php. If you can/want do this, edit your theme’s header.php and add the following inside the head tag: 

    <script>
    (function($){
        window.ps2id_special_params={ offset: _ps2idCalcOffset() };
        function _ps2idCalcOffset(){
            return $(".site-header.sticky").outerHeight(true) + $(".mega-menu-wrap").outerHeight(true) + 100;
        }
    })(jQuery);
    </script>

    The above will calculate both sticky menus height and add extra pixels (e.g. 100) for the space between them. 

    Another way would be to use plugin’s advanced offset via the “Auto-generate #ps2id-dummy-offset element” option. You’ll have to enable this option and then style (via CSS) the #ps2id-dummy-offset element to match both sticky menus combined height. You can see more info about the feature here: 
    http://manos.malihu.gr/page-scroll-to-id-for-wordpress/#plugin-settings-offset-dummy

    Let me know 🙂 

    • This reply was modified 4 years, 9 months ago by malihu.
    Thread Starter austin113

    (@austin113)

    So my client looked at the site and wanted a different type of sub-menu and also wanted to stick the ticker to the header. The menu in question is now made up of siteOrigin Hero Widgets linked to the corresponding sections below and is sticking via the Sticky Menu & Sticky Header Plugin. The ticker is being pinned via simple custom CSS code.

    Ultimately, and unfortunately, my issue remains the same however the variables have changed.

    Any chance you can take another look and see what you can suggest?

    Thank you again in advance!

    Plugin Author malihu

    (@malihu)

    @austin113 The problem with the new menu is that it does not contain link elements (</a>). It only contains li and div elements that are handled by another script.

    “Page scroll to id” works only with normal links with actual URLs (like the ones you had before). It cannot work with custom elements from other scripts.

    Can you make the 3 boxes links, with URLs #consult, #mentor etc.?

    If you can change the boxes to normal links (i.e. anchor elements), the js script I posted before should change to:

    (function($){
    	window.ps2id_special_params={ offset: _ps2idCalcOffset() };
    	function _ps2idCalcOffset(){
    		return $(".site-header.sticky").outerHeight(true) + $("#pg-241-1").outerHeight(true) + 100;
    	}
    })(jQuery);
    • This reply was modified 4 years, 9 months ago by malihu.
    Thread Starter austin113

    (@austin113)

    Okay. I got the image buttons to be normal links. I made the text on them the linked item and not the image itself. This has made a great improvement but still doesn’t line up correctly.

    I also added your code to the header.php file and tried increasing and decreasing the number of added pixels and it didn’t seem to affect it. It’s super close now though.

    Any ideas?

    Plugin Author malihu

    (@malihu)

    Ok. The html has changed a bit so try changing the script to:

    (function($){
    	window.ps2id_special_params={ offset: _ps2idCalcOffset() };
    	function _ps2idCalcOffset(){
    		return $(".site-header.sticky").outerHeight(true) + $("#pg-241-1 > .is_sticky").outerHeight(true) + 100;
    	}
    })(jQuery);
    Thread Starter austin113

    (@austin113)

    I updated the code you sent and still no change. I think right now it is lining up underneath the hyperlinked text of the button correctly, but not the rest of the image around the hyperlinked text.

    Again I have put in increasingly higher numbers in the code and they don’t change the position at all.

    I have also emailed you a screenshot of my header.php as it may shed more light for you, since I don’t seem to be able to post them here in the forum.

    Plugin Author malihu

    (@malihu)

    Can you try placing the js code in your header.php after the wp_head(); function?

    Thread Starter austin113

    (@austin113)

    I moved the code under the wp_head function and it still wasn’t changing when I put in different numbers.

    As a temporary solution, I have added blank rows above each of the sections I wanted to link and changed the hyperlink from the content of the sections to the blank row. It’ll work in the meantime, but should still allow us to keep looking and testing to get this adjusted properly.

    Plugin Author malihu

    (@malihu)

    OK, we probably need to use a different approach, like using plugin’s “Auto-generate #ps2id-dummy-offset element” option.

    For this we would need to remove the custom js script from the header.php and enable the “Auto-generate #ps2id-dummy-offset element” option in plugin settings. Then, add the following CSS:

    #ps2id-dummy-offset{
      /* site header height + horizontal strip height + links height */
      height: calc(196px + 62px + 197px);
    }
    @media only screen and (min-width: 768px){
      #ps2id-dummy-offset{
        /* some other offset for mobile */
      }
    }

    This way we can simulate the 3 different sticky elements heights into a single element (#ps2id-dummy-offset) height.

    site header and horizontal strip heights seem to remain the same in desktop and mobile. The 3 links boxes should change on mobile, as right now they occupy all screen.

    Thread Starter austin113

    (@austin113)

    Hooray!! It works perfectly now! I had to tweak the numbers in the code a little but now it lines up correctly!

    Thank you for pointing out the issue on mobile. I think I now have the tools and confidence to be able to handle working on it there.

    Thank you so much for your consistent help and support and for designing this plugin it is a lifesaver!!

    Plugin Author malihu

    (@malihu)

    You’re welcome! Glad I helped 🙂
    I’m marking this as resolved but if you need more help, let me know.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Offset is not working for me..’ is closed to new replies.