jQuery detecting scroll

jQuery detecting scroll

[cc lang=”objc” escaped=”true” width=”90%” theme=”default” line_numbers=”on”]
$( document ).ready(function() {
function setnavigation(){
if ( jQuery(window).scrollTop() > 60 ) {
showfixedmenu();
} else {
shownormalmenu();
}
}
setnavigation();

$(window).scroll(function() {
setnavigation();
});
});

Drop-in code for Bootstrap

[cc lang=”objc” escaped=”true” width=”90%” theme=”default” line_numbers=”on”]
var fixedmenushow = false;
var normalmenushow = true;

function showfixedmenu(){
if(!fixedmenushow){
console.log(‘showfixedmenu’);
fixedmenushow = true;
normalmenushow = false;
$(“.navbar”).fadeOut(200, function() {
$(“header div#nav-filler”).css(‘height’,’72px’);
$(“.navbar”).addClass(“navbar-fixed-top”);
$( “.navbar” ).fadeIn(200, function(){

});
});
}
}

function shownormalmenu(){
if(!normalmenushow){
console.log(‘shownormalmenu’);
normalmenushow = true;
fixedmenushow = false;
$(“.navbar”).fadeOut(200, function() {
$(“header div#nav-filler”).css(‘height’,’auto’);
$( “.navbar” ).removeClass( “navbar-fixed-top” );
$( “.navbar” ).fadeIn(200, function(){

});
});
}
}

function setnavigation(){
if ( jQuery(window).scrollTop() > 60 ) {
showfixedmenu();
} else {
shownormalmenu();
}
}
setnavigation();

$(window).scroll(function() {
setnavigation();
});