diff --git a/demo/indexWithDelay.html b/demo/indexWithDelay.html new file mode 100644 index 0000000..10a3659 --- /dev/null +++ b/demo/indexWithDelay.html @@ -0,0 +1,88 @@ + + + + + + + + Auto-hiding fixed navbar for Bootstrap + + + + + + + + + + +
+ +

+ Long content... +

+

+ Long content... +

+

+ Long content... +

+

+ Long content... +

+

+ Long content... +

+

+ Long content... +

+ +
+ + + + + + + diff --git a/src/jquery.bootstrap-autohidingnavbar.js b/src/jquery.bootstrap-autohidingnavbar.js index cef93b8..5b24dde 100644 --- a/src/jquery.bootstrap-autohidingnavbar.js +++ b/src/jquery.bootstrap-autohidingnavbar.js @@ -9,13 +9,15 @@ _previousScrollTop = null, _windowHeight = $window.height(), _visible = true, + _timeoutID = null, _hideOffset, defaults = { disableAutohide: false, showOnUpscroll: true, showOnBottom: true, hideOffset: 'auto', // "auto" means the navbar height - animationDuration: 200 + animationDuration: 200, + hideAfter: 0 //0 means delayed hide not active }; function AutoHidingNavbar(element, options) { @@ -54,6 +56,12 @@ queue: false, duration: autoHidingNavbar.settings.animationDuration }); + if(autoHidingNavbar.settings.hideAfter > 0) { + if(_timeoutID != null){ + window.clearTimeout(_timeoutID); + } + _timeoutID = window.setTimeout(hide, autoHidingNavbar.settings.hideAfter, autoHidingNavbar); + } _visible = true; }