Skip to content

Instantly share code, notes, and snippets.

@lyonsun
Created March 8, 2014 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyonsun/9431547 to your computer and use it in GitHub Desktop.
Save lyonsun/9431547 to your computer and use it in GitHub Desktop.
bootstrap, make navbar stick to top when scrolling down
function setSkrollr(){
var objDistance = $navbar.offset().top;
$(window).scroll(function() {
var myDistance = $(window).scrollTop();
if (myDistance > objDistance){
$navbar.addClass('navbar-fixed-top');
}
if (objDistance > myDistance){
$navbar.removeClass('navbar-fixed-top');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment