From ea67189c271a339a707bc2a292773c1e3fc2ed49 Mon Sep 17 00:00:00 2001 From: brouillon Date: Wed, 27 Sep 2017 07:27:36 +0200 Subject: [PATCH] Collapse navbar if page is not at top on load --- js/agency.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/agency.js b/js/agency.js index 75475e3..52e8c05 100644 --- a/js/agency.js +++ b/js/agency.js @@ -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