All Projects → damianwajer → ml-stack-nav

damianwajer / ml-stack-nav

Licence: MIT License
Customizable, responsive, accessible, easy-to-use multi-level stack navigation menu with slide effect.

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to ml-stack-nav

Sidr
Sidr is a jQuery plugin for creating side menus and the easiest way for doing your menu responsive.
Stars: ✭ 2,924 (+14520%)
Mutual labels:  jquery-plugin, navigation, responsive, menu
React Responsive Navbar
Nothing crazy, nothing flashy, just a simple, flexible & completely customisable responsive navigation bar component.
Stars: ✭ 42 (+110%)
Mutual labels:  navigation, responsive, menu
Hc Offcanvas Nav
JavaScript library for creating toggled off-canvas multi-level navigations, allowing endless nesting of submenu elements, supporting swipe gestures, keyboard interactions and ARIA attributes.
Stars: ✭ 201 (+905%)
Mutual labels:  jquery-plugin, navigation, menu
vue-bottom-navigation
Vue bottom navigation
Stars: ✭ 56 (+180%)
Mutual labels:  navigation, menus, menu
priority-plus
A modern implementation of the priority plus navigation pattern.
Stars: ✭ 30 (+50%)
Mutual labels:  navigation, responsive, menu
Quickmenu
The new era of mobile navigation for the web, we're out of hamburgers.
Stars: ✭ 119 (+495%)
Mutual labels:  navigation, responsive, menu
Jquery.sumoselect
A jQuery Single/Multi Select plugin which can be used on almost any device
Stars: ✭ 527 (+2535%)
Mutual labels:  jquery-plugin, responsive, customizable
ContextMenuSwift
A better version of iOS 13 Context Menu
Stars: ✭ 162 (+710%)
Mutual labels:  menus, menu
SidebarOverlay
Yet another implementation of sidebar menu, but here your menu appears over the top view controller.
Stars: ✭ 66 (+230%)
Mutual labels:  navigation, menu
navigator
🧿 Build navigation or menu for Laravel and Awes.io. Unlimited complexity and depth, with permissions and sorting support.
Stars: ✭ 47 (+135%)
Mutual labels:  navigation, menu
bsnav
An extended Bootstrap 4 menu with a bunch of utilities
Stars: ✭ 90 (+350%)
Mutual labels:  navigation, menu
guillotine
jQuery plugin to crop images within an area (fully responsive), allowing to drag (touch support), zoom and rotate.
Stars: ✭ 321 (+1505%)
Mutual labels:  jquery-plugin, responsive
drawer
A touch-enabled drawer component for the modern web.
Stars: ✭ 26 (+30%)
Mutual labels:  jquery-plugin, menu
ekzo
💫 Functional Sass framework for rapid and painless development
Stars: ✭ 32 (+60%)
Mutual labels:  responsive, bem
vue-burger-button
🍔 vue-burger-button is a functional component, which is faster than a regular component, and is pretty small (JS min+gzip is lower than 700b and CSS min+gzip is lower than 400b).
Stars: ✭ 41 (+105%)
Mutual labels:  hamburger-menu, menu
scalem
A jQuery plugin to make any element scalable (responsive).
Stars: ✭ 33 (+65%)
Mutual labels:  jquery-plugin, responsive
Accordion
Silky-smooth accordion widgets with no external dependencies.
Stars: ✭ 32 (+60%)
Mutual labels:  navigation, menu
ElDewrito-Menu
Possible replacement for Halo Online's UI heavily based on Halo: Reach
Stars: ✭ 22 (+10%)
Mutual labels:  menu, customizable
navbar.js
Modern Navigation Component
Stars: ✭ 47 (+135%)
Mutual labels:  navigation, menu
lazeemenu
Multi-level sidebar menu - JQuery plugin
Stars: ✭ 40 (+100%)
Mutual labels:  jquery-plugin, menu

Multi-level stack navigation (jQuery mlStackNav)

Customizable, accessible, easy-to-use multi-level stack navigation menu.

The purpose behind this project is to provide a fully functional, responsive and usable navigation with minimal styling, which can also be used as a good starting point to implement your own custom design.

Demo

https://damianwajer.github.io/ml-stack-nav/

Requirements

Browser support

  • All modern browsers such as Chrome, Firefox, Safari, Edge (last 2 versions) and Internet Explorer 10+
  • Stock browser on Android 4.0+ and Safari on iOS 7+
  • Internet Explorer 9 is also supported but without transition animations and with some additional CSS (I recommend placing IE 9 rules within conditional comment in <head> section of the HTML file or in some separate .css file with other IE 9 fixes):
<!--[if IE 9]>
<style type="text/css">
    .ml-stack-nav {
        display: none;
    }
    
    .ml-stack-nav.is-open {
        display: block;
    }
</style>
<![endif]-->

Download

Usage

To get started just add required styles:

<link rel="stylesheet" href="dist/ml-stack-nav.css">

Include jQuery:

<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>

…and the plugin JS file:

<script src="dist/ml-stack-nav.js"></script>

Navigation HTML markup should be placed at the top-level position directly under the body element in the document to avoid the stacking context issues.

<body>
    <nav class="ml-stack-nav js-ml-stack-nav">(…)</nav>
</body>

Please see index.html file for demo and code example.

Finally, initiate the plugin:

$(".js-ml-stack-nav").mlStackNav();

The dist/ml-stack-nav.js and dist/ml-stack-nav.css files contain all what is necessary for the menu to work properly and they should not be edited directly. Unlike them, dist/ml-stack-nav-theme.css theme file provides example styles for the navigation and can be edited, extended or completely replaced with your own styles (the minified files .min.css and .min.js are also available in dist directory and you can use them on production instead of regular ones).

Advanced usage

The goal behind the mlStackNav is to provide a good starting point to implement navigation with custom design, so advanced usage is highly recommended. In order to take full advantage of the mlStackNav, please keep in mind its most important features:

  • separation of the appearance and the functionality
  • CSS class names according to BEM methodology
  • state rules inspired by SMACSS (Scalable and Modular Architecture for CSS)
  • js- prefixed classes to decouple JavaScript classes from CSS ones

Multiple instances

Multi-level stack navigation also supports multiple instances of the menu.

You can use it to implement as many navigation menus as you want by simply initializing different menus with separate toggle buttons. For example:

$(".js-ml-stack-nav").mlStackNav({
    navToggleSelector: ".js-ml-stack-nav-toggle"
});

$(".js-ml-stack-nav-2").mlStackNav({
    navToggleSelector: ".js-ml-stack-nav-2-toggle"
});

or by providing jQuery selector inside data-nav-toggle attribute:

<button type="button" class="ml-stack-nav-toggle" id="ml-stack-nav-toggle-1">(…)</button>

<nav class="ml-stack-nav js-ml-stack-nav" data-nav-toggle="#ml-stack-nav-toggle-1">(…)</nav>

<button type="button" class="ml-stack-nav-toggle" id="ml-stack-nav-toggle-2">(…)</button>

<nav class="ml-stack-nav js-ml-stack-nav" data-nav-toggle="#ml-stack-nav-toggle-2">(…)</nav>

Navigation with JavaScript disabled

mlStackNav can still works in its basic form even when JavaScript is disabled. You just need to make sure that:

  • no-js class is present on the top-level element on your page (e.g. on html element: <html class="no-js">
  • no-js is removed before mlStackNav initialization, e.g. $("html").removeClass("no-js")
  • a link with the anchor matching the navigation id is used instead of a button (e.g. <a class="ml-stack-nav-toggle"> and <nav id="ml-stack-nav-1" class="ml-stack-nav js-ml-stack-nav">)

Options

navToggleSelector

Type: String

Default: .ml-stack-nav-toggle

jQuery selector with toggle button element (or a link).

openClass

Type: String

Default: is-open

Class name for open menu items (also background items below current level).

activeClass

Type: String

Default: is-active

Class name for currently active menu item and active toggle button.

zIndexValue

Type: Number

Default: 900

CSS z-index property for navigation menu container.

Methods

Using methods you can interact with the plugin programmatically from within your scripts, e.g. you can open or close the navigation on some custom event.

Available methods:

  • open Open the navigation.
  • close Close the whole navigation.
  • toggle Open the navigation if it's closed, close if it's open.
  • moveBack Move to the previous menu level.
  • isOpen Check if the navigation is currently open.

Example:

$(".ml-stack-nav__link").on("click", function () {
    $(".js-ml-stack-nav").mlStackNav("close");
});

Events

Using events you can run some custom code, e.g. when menu opens or closes.

  • show.ml-stack-nav This event is triggered before the navigation opens (immediately when the open method is called).
  • hide.ml-stack-nav This event is triggered before the navigation closes (immediately when the close method is called).

Example:

$(".js-ml-stack-nav")
    .on("show.ml-stack-nav", function (e) {
        console.log(e);
        alert("The navigation will open!");
    })
    .on("hide.ml-stack-nav", function (e) {
        console.log(e);
        alert("The navigation will close!");
    });

TODO

  • add swipe support
  • off-canvas mode (push)
  • more themes
  • tests

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, open a pull request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].