jQuery Plugin For Auto-hide Top Navigation Bar - Hidescroll.js

jQuery Plugin For Auto-hide Top Navigation Bar - Hidescroll.js
File Size: 13.6 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Hidescroll.js is a tiny jQuery plugin which allows to hide the top navigation bar as you scroll down, however when you scroll up it would show it self again.

How to use it:

1. Create a sticky top navigation bar in your web page.

<div class="navbar">
  ...
</div>

2. Include the jQuery library and the jQuery Hidescroll.js script at the bottom of the page.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="jquery.hidescroll.js"></script>

3. Initialize the plugin with default options.

$('.navbar').hidescroll();

4. Style the top navigation bar whatever you like.

.navbar {
  -moz-transition: all 150ms cubic-bezier(0.165, 0.84, 0.44, 1);
  -webkit-transition: all 150ms cubic-bezier(0.165, 0.84, 0.44, 1);
  transition: all 150ms cubic-bezier(0.165, 0.84, 0.44, 1);
  width: 100%;
  height: 50px;
  line-height: 50px;
  background: #95a5a6;
  position: fixed;
  top: 0;
  left: 0;
  color: #fff;
  text-align: center;
}

.navbar.stick {
  height: 50px;
  line-height: 50px;
}

.navbar.stick.visible { background-color: #e74c3c; }

.navbar.stick.hidden { top: -50px; }

5. Available options.

  • offset: 0: How far scroll distance (from top) navbar sticking has taken place
  • interval: 250: How often (in ms) is to be checked current scroll position and direction
  • stickClass: 'stick': Class used on navbar stick
  • visibleClass: 'visible': Class used on navbar stick is visible
  • hiddenClass: 'hidden': Class used on navbar stick is hidden

This awesome jQuery plugin is developed by jedrzejchalubek. For more Advanced Usages, please check the demo page or visit the official website.