Fix Vantage Theme Menu Scroll Bug

Written by Dan Mossop

There is a bug in the way the SiteOrigin's Vantage Theme handles its sticky menu.

In order to achieve the sticky menu effect, the theme checks if the user has scrolled down far enough, and if so creates a copy of the current menu bar and places it in a fixed position at the top of the page. The idea is that this copy will cover up the original menu bar and create the sticky menu effect. This works, but only to a point.

The Sticky Menu Bug

A problem occurs if the user has a sub-menu open while scrolling down. The sub-menu is not fully covered by the new sticky menu, so it can still be seen as it scrolls up the page. Furthermore, the sub-menu is actually set to be in front of the new sticky menu, giving the effect that it is the sticky menu's sub-menu which is being displayed and slowly disappearing off the top of the page instead of staying in place below the menu.

Fixing the Sticky Menu Bug

One way to fix this issue is to get rid of the copied menu entirely and then use some JavaScript to make the original menu itself become sticky when the user scrolls down. That way there is only one menu being displayed and no strange sub-menu effects occur.

First, we add some CSS to the theme to hide the copy, create a new class with the rules we need to make the menu sticky, and add a slight adjustment so it will work when the wordpress admin bar is showing:

.sticky { display:none; }
.sticky2 { position:fixed; top:0; z-index:1000; width:100%; } 
body.admin-bar .sticky2{ padding-top:32px; }

Then we need to trigger addition of the new sticky2 class to the menu at the right time (i.e. when the user scrolls down). We do this with the following JavaScript, which also does some adjusting of the positions of surrounding elements in order to make everything look right:

var elTop;
var $window = jQuery(window);
 
jQuery(document).ready(function($) {
   elTop = $('.main-navigation').offset().top;
   $window.scroll(function() {
		var nav = jQuery('.main-navigation');
		var adminoffset = (jQuery('body').hasClass('admin-bar'))?32:0;
		var issticky = ($window.scrollTop() > elTop - adminoffset);
		nav.toggleClass('sticky2', issticky);
		jQuery('#main-slider').css('margin-top', issticky?(nav.height()+adminoffset):0);
	});
});

Seamlessly Integrate Seamless Features into Your Posts!

Troubleshooting themes or plugins can be complex. Enhance your WordPress site's engagement and drive conversions effortlessly with WP Magic CTAs. This plugin creates AI-powered, targeted call-to-actions for each post, perfect for directing traffic and promoting offers while you focus on resolving issues like the Vantage theme bug.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest Posts

Set a Custom Start Value in Divi Number Counter Modules

Adjusting the starting value for Number Counter modules in Divi enables you to create more dynamic and tailored animations, such as counters that begin at a specific number rather than the default zero. This can enhance the presentation of statistics or milestones on...

Create a FAQs Accordion Module in Divi

Building an organized and interactive FAQs section on your website can enhance user experience by providing quick answers to common questions in a visually appealing, space-saving format. Displaying FAQs in an accordion allows visitors to easily browse topics and find...

Hide the Page Title in the Hello Elementor Theme

Hiding the page title in the Hello Elementor theme allows you to create a cleaner and more customized page layout, free from default headings that may not fit your design. This is particularly useful for landing pages or custom content layouts where the default page...

How to Hide a Divi Module When Scrolling Up or Down

In this quick tutorial, I’ll show you how to hide a Divi module when scrolling in a specific direction (up or down), so that the module only shows when you want it to. This is especially useful when using Divi’s Scroll Effects feature and you have a effect you want to...

Random Posts