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 Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts