add a 'heightFunc' and 'peek' setting #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 function to find the height of the navbar. Our navbar has padding, though, which
height
doesn't take into account. jQuery'souterHeight
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.Or with a custom function:
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!