istvan-ujjmeszaros/bootstrap-autohidingnavbar — pull request #8 by mwcz (2014-12-03 19:19:49+00:00)
Title: add a 'heightFunc' and 'peek' setting

I added two settings for my own use and figured I'd offer them up in case they're useful for anyone else.

autoHidingNavbar uses jQuery's [height][height] function to find the height of the navbar. Our navbar has padding, though, which `height` doesn't take into account. jQuery's [`outerHeight`][outerHeight] is needed when padding, border, or margin need to be included in the height calculation.

In order to make it flexible, I added a `heightFunc` option that accepts any height-calculating function.

Here's an example of using heightFunc to specify jQuery's `outerHeight` function.

header_nav.autoHidingNavbar({
heightFunc : $.fn.outerHeight,
peek : 2
});

Or with a custom function:

function getHeight(el) {
return el.height; // some custom height-finding math
}

header_nav.autoHidingNavbar({
heightFunc : getHeight,
peek : 2
});

The `peek` parameter there is an option that allows the navbar to stay partially visible even when "hidden". On some sites, designers like to leave a tiny sliver of the navbar visible, just to remind the user that it's there. This way it doesn't disappear completely when hidden.

A peek value of `2` makes 2px worth of the navbar "peek" out from under the viewport.

The default value for heightFunc is still `$.fn.height` and the default for peek is 0, so this should be completely backwards-compatible.

I added the options to the README in this PR. If there's any other work you'd like me to do, let me know. Or if this isn't something you're interested in, that's okay too!

[height]: http://api.jquery.com/height/
[outerHeight]: http://api.jquery.com/outerHeight/