okayNav jQuery Plugin
You know how navigations have only a desktop and a mobile state, right? I thought, "this might cost people money because it requires additional click for users to reach even the most important pages."
This navigation aims at progressively collapsing navigation links into an off-screen navigation instead of doing it for all the links at the same time. Check out this example:
Or play with it on CodePen.
How to Use
This is the code used in the example:
LogoHomeShopBlogServicesContactsAbout usTestimonials<!-- /header -->
Include the CSS:
Include the library:
And here's the JS to initialize it:
var navigation = ;
okayNav depends on jQuery. Tested with jQuery 1.10+ but should work with lower versions. The stylization of okayNav comes in a commented LESS and CSS.
okayNav supports IE9+, Firefox, Chrome. Transitions work in IE10+.
var navigation =;
Open the off-screen part:
Close the off-screen part
Toggle the off-screen part
Recalculate what should be visible and what shouldn't:
Get the nav's parent element:
Get the nav's visible part:
Get the nav's off-screen part:
Get the nav's toggle icon:
Get the nav children's total width:
Destroy the nav, make everything visible, disable all events:
The following features will be implemented at the next versions:
- AMD/CommonJS support
- Multi-level navigation
- Option to prioritize certain nav items
- Option to hide or show all nav items instead of doing it progressively
Pull requests are appreciated.
Licensed under the MIT License.
Please use the GitHub issues for support requests. If you need someone to implement okayNav for you, hit me up at email@example.com.
Reintroduced throttling on window resize.
- Flexbox is now optional; nav will work with floats too;
- Resolved a bug when maximizing the browser.
- Swipe actions are now available;
- Swipe can be enabled or disabled;
- You can adjust the threshold after which the swipe action will trigger;
- Added extra callbacks;
- Callbacks are now camelCased;
- The beforeOpen/beforeClose callbacks now only trigger if swipe is disabled (for obvious reasons).
Scroll up to see the defaults for more information!
Resize events are now a lot more efficient
First public version
Tell me what you've created
Many thanks to @Bloodb0ne for the enormous help with swipe actions!
Buy me a beer
I appreciate good beer and good coffee. If you find this plugin useful and want to say thanks, there's no better way to do it. My PayPal is available below.