Collapse navbar if page is not at top on load

This commit is contained in:
brouillon 2017-09-27 07:27:36 +02:00 committed by GitHub
parent 772584e013
commit ea67189c27

View File

@ -26,13 +26,16 @@
offset: 54
});
// Collapse the navbar when page is scrolled
$(window).scroll(function() {
var navbarCollapse = function() {
if ($("#mainNav").offset().top > 100) {
$("#mainNav").addClass("navbar-shrink");
} else {
$("#mainNav").removeClass("navbar-shrink");
}
});
};
// Collapse now if page is not at top
navbarCollapse();
// Collapse the navbar when page is scrolled
$(window).scroll(navbarCollapse);
})(jQuery); // End of use strict