Skip to content

Fixes subnav to the top when it scrolls out of view (intended to work with bootstrap)

License

Notifications You must be signed in to change notification settings

ForbesLindesay/booting-nav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

booting-nav

Intended to fix navigation to the top when it scrolls out of view (works great with bootstrap). This library can easilly be used to add a class to something when it scrolls out of view, and remove the class when it scrolls back into view.

Dependency Status NPM version

Usage

This library can be built to use standalone, just download the github repo and then do:

$ npm install browserify -g
$ npm install
$ browserify index.js --standalone boot > boot.js

You can then use boot instead of require('booting-nav').

Example usage:

var boot = require('booting-nav')
var $ = document.getElementById.bind(document)

boot($('blue'))
boot($('red'), {offset: 40})
boot($('green'), {offset: 80})
boot($('orange'), {offset: 120, minWidth: '400px'})

This results in each block sticking to the top at the appropriate offset. Then minWidth parameter is oftne useful for mobile layouts.

You can skip the auto-generated class and just have your own class used instead by adding the cls option:

boot($('orange'), {cls: 'nav-fixed-top'})

License

MIT

About

Fixes subnav to the top when it scrolls out of view (intended to work with bootstrap)

Resources

License

Stars

Watchers

Forks

Packages

No packages published