Download
Demo
- Overview
- Documents
User Rating: 4.6/5 ( 1 votes)
Your Rating:
Bootstrap Auto-Hiding Navbar is an extension for Bootstrap's fixed navbar which hides the navbar while the page is scrolling downwards and shows it the other way. The plugin is able to show/hide the navbar programmatically as well.
Source: virtuosoft.eu
1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/css/bootstrap.min.css"> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/js/bootstrap.min.js"></script> <script src="dist/jquery.bootstrap-autohidingnavbar.min.js"></script>
2. HTML
<div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Auto hiding navbar</a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li class="divider"></li> <li class="dropdown-header">Nav header</li> <li><a href="#">Separated link</a></li> <li><a href="#">One more separated link</a></li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="#">Default</a></li> </ul> </div> </div> </div>
3. JAVASCRIPT
$("div.navbar-fixed-top").autoHidingNavbar();
4. OPTIONS
When calling $(".navbar-fixed-top").autoHidingNavbar() you can pass a parameters object with zero or more of the following:
OPTION | DEFAULT | DESCRIPTION |
---|---|---|
disableAutohide | false | Set this to true if you want to show/hide the navbar programmatically. |
showOnUpscroll | true | The navbar shows up when scrolling the page upwards (when set to false then it shows only when scroll is on page's top). |
showOnBottom | true | The navbar shows up when scroll reaches the page's end. |
hideOffset | 'auto' | Hides the navbar after scrolling that much pixel. auto means the navbar's height. |
animationDuration | 200 | The duration of the show and hide animations in milliseconds. |
5. METHODS
Here are the available methods that can be called with the following syntax:
$('.navbar-fixed').autoHidingNavbar('setDisableAutohide', true); $('.navbar-fixed').autoHidingNavbar('hide');
METHOD | DESCRIPTION |
---|---|
setDisableAutohide(value) | Call to change the `disableAutohide` parameter. |
setShowOnUpscroll(value) | Call to change the `showOnUpscroll` parameter. |
setShowOnBottom(value) | Call to change the `showOnBottom` parameter. |
setHideOffset(value) | Call to change the `hideOffset` parameter. |
setAnimationDuration(value) | Call to change the `animationDuration` parameter. |
show() | Shows the navbar programmatically. |
hide() | Hides the navbar programmatically |
destroy() | Destroys the plugin instance. |