Skip to content
forked from thednp/navbar

Minimal, cross-browser script for menu navigation.

License

Notifications You must be signed in to change notification settings

metabake/navbar.js

 
 

Repository files navigation

Navbar - minimal navigation script

This is a script that most web developers need for a quick site navigation, built with Native Javascript and supported on all major browsers as well as legacy browsers starting with IE8.

NPM Version NPM Downloads jsDeliver

Demo

Download the package and check the demo folder, or check it online here.

Features

  • opens submenus on mouseenter, by adding open and open-position classes to the menu item, in rapid succession
  • hides submenus on mouseleave, by removing the above classes in a delayed succesion
  • super light script, 1.2k in size when minified
  • responsive design ready
  • super light and easy to customize CSS
  • 3 sets of positions top (main), left or right
  • animations are based on position
  • LESS/SCSS sources ready
  • DATA API allows you to automatically initiate without JS invocation
  • cross-browser supported

NPM/Bower

You can install this through NPM or bower respectively:

$ npm install navbar.js
# or
$ bower install navbar.js

Browser Usage

Download the latest package. unpack and inspect the contents. You need to copy the navbar.js and navbar.css or their minified variations to your app assets folders as follows. Link the required CSS in your document <head> tag

<link href="../assets/css/navbar.css" rel="stylesheet">

Link the required JS in your document <body> tag

<script src="../assets/js/navbar.js"></script>

Initiate the function for your elements at the end of your <body> tag

<script>
var myMenu = new Navbar('selector');
</script>

To use the DATA-API, you need to provide the data-function="navbar" attribute to your menu, like so:

<ul class="nav" data-function="navbar">
  <li><a href="#">Link Title</a></li>
  <li><a href="#">Another Link Title</a></li>
</ul>

Legacy browsers need classList polyfill, so give them minifill.

Node

On node.js environments

// get and store it
var Navbar = require("navbar.js");

// initialize it
var myMenu = new Navbar('selector');

Build Tools

You have 3 build tools for building custom builds

  • $ npm run min-js - to minify the navbar.js
  • $ npm run build-less - to compile and minify the navbar.less
  • $ npm run build-scss - to compile and minify the navbar.scss

License

MIT License

About

Minimal, cross-browser script for menu navigation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CSS 62.5%
  • JavaScript 37.5%