Jump to content

Archived

This topic is now archived and is closed to further replies.

titus

HELP: JS for un-hiding and changing main menu to white background on scroll

Recommended Posts

titus

Hi, I'm trying to unhide the menu that uses the .fixed class. I would also like to add a class that turns the background from transparent to white after you scroll. 

 

File: /wp-content/themes/voyant/sections/menu-voyant/voyant-menu.js

 

I have commented out this, and it seems to unhide everything fine:

/* $window.on('scroll', function(event) {
					if( $window.width() <= 768){
						$fixed.removeClass('hide-menu');
						$fixed.addClass('show-menu');
						menuVisible = true;
						return;
					}
					if( $window.height() + 150 >= $site.height() ){
						$fixed.addClass('test');
						menuVisible = true;
						return;
					}

					if( $window.height() + 150 >= $site.height() ){
						$fixed.removeClass('hide-menu');
						$fixed.addClass('show-menu');
						menuVisible = true;
						return;
					}

					if( $window.scrollTop() > 150 && !menuVisible){
						$fixed.removeClass('hide-menu');
						$fixed.addClass('show-menu');
						menuVisible = true;
					}else if( menuVisible = true &&  $window.scrollTop() < 150){
						$fixed.addClass('hide-menu');
						$fixed.removeClass('show-menu');
						menuVisible = false;
					}
				});
*/

I also want to add in a class which will turn the background white when I scroll down. So I reused a portion of the commented-out section and rewrote it like this: 

$window.on('scroll', function(event) {
if( $window.height() + 150 >= $site.height() ){
$fixed.addClass('white-background');
menuVisible = true;
return;
}
});

The first part works, but the second part doesn't. What am I missing?

 

Thanks,

Share this post


Link to post
Share on other sites
titus

So for what I needed to do you can simply comment-out the section I posted above. But the fix I proposed for the white background didn't work. So what you can do is simply use the following ID's and Classes to call out the menu when it's hidden vs fixed. These two elements change regardless of the voyent-menu.js. Once you scroll down it's considered fixed.

 

#fixed-top.is-fixed

 

#fixed-top.is-not-fixed

 

Thanks,

David

Share this post


Link to post
Share on other sites

  • Similar Content

    • jagipson
      By jagipson+
      Tmeister"] I started a topic a few days ago but never heard anything @[member="Danny suggested I start a new topic and mention your username 
       
      I have a section I want to fit to the window height but when the menu is above its not working its leaving a gap in the bottom see the URL here http://recruiterseo.com/cato/ but if I remove the menu or display:none on the menu the section height works correctly 
       
      Thanks for the help
    • jagipson
      By jagipson+
      I have a section I want to fit to the window height but when the menu is above its not working its leaving a gap in the bottom see the URL here http://recruiterseo.com/cato/
    • sruehle
      By sruehle+
      Hi,
       
      i accidentally deleted the "Menu Voyant" in the fixed section.
       
      I can't drag the "Menu Voyant" Section oder the fixed area again. It does not seem to "stick". Instead, Menu Voyant is placed in the page instead of the fixed section.
       
      Please help.
       
      Thanks,
       
      Stefan
    • john_mckay
      By john_mckay
      I incorrectly added a time value to the start time value for the videoslider
       
      ( { videoURL:'dQx9WOq0KOA', containment:'#player-uz1errk', showControls:false, loop:true, mute:true, startAt:0:00, stopAt:0, opacity:.4, addRaster:false, quality:'default' }) 
       
       
      This now gives me  a Uncaught SyntaxError: Unexpected token :
      and the video will not show.
      The DMS editor will now not load for me to correct. How can I edit this value back to the numeric 0 that it should be?
       
      thanks
       
      John
    • ea/
      By ea/+
      Hi Enrique,
       
      What code do I need to change the colour for my Voyant Menu from white to my primary site colour, and where should I put it? I'd like to reverse the colour scheme from the default white font on colour I select to white background with font colour I select.
       
      Thanks for your help! 
       
      ea/
×