Skip to content

Instantly share code, notes, and snippets.

@carlosonweb
Last active June 16, 2017 03:49
Show Gist options
  • Save carlosonweb/dd1fd1fb8280bc60120f40980d81035c to your computer and use it in GitHub Desktop.
Save carlosonweb/dd1fd1fb8280bc60120f40980d81035c to your computer and use it in GitHub Desktop.
Beaver Themer Scrolling Menu Bar.
/**
*
* Following CSS may be needed
* -----------------------------
#header-scrolling-menu {
opacity: 1.0 !important;
index: 10;
}
Scroll Direction code courtesy of:
https://stackoverflow.com/questions/4326845/how-can-i-determine-the-direction-of-a-jquery-scroll-event
*-------------------------------
*/
jQuery(document).ready(function($){
lastScrollTop = 0;
if( typeof window.FLBuilderConfig === 'undefined' || window.FLBuilderConfig === null ) {
$('#header-scrolling-menu').hide();
}
});
jQuery(window).scroll(function(event){
var $ = jQuery;
var st = $(this).scrollTop();
if (st > lastScrollTop){
// downscroll
if ( st > 200){
// display the sticky menu
$('#header-scrolling-menu').show();
}
} else {
// upscroll code
if ( st <= 200 ){
// hide the sticky menu
$('#header-scrolling-menu').hide();
}
}
lastScrollTop = st;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment