0.0.2 • Published 5 years ago

mgn-menu v0.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

mgn-menu ( Don't Need jQuery )

Implement function to operate hamburger menu's opening and closing.
When menu button is clicked, class is added/deleted in response to menu button and global navigation.

  • Target browser : IE9+

Install

npm i mgn-menu -S

Or Download raw data

↓ download "mgn-menu.js"


Import

import mgnMenu from 'mgn-menu';

Constructor

new mgnMenu( element [, option] )
ArgumentData typeDefaultDescroption
elementString-(Required)Specify target element.ex) ".j-menu"
optionObject-ex) option = { globalNav: "#globalnav", activeName: "open", noScroll: false, closePoint: 768}
OptionData typeDefaultDescroption
globalNavString"#globalnav"Specify global navigation's ID or Class.
activeNameString"active"Specify class to assign.
noScrollBooleantrueSpecify whether to scroll back content.
closePointNumberNullSpecify the boundary value to forcefully close the global navigation.

Method

MethodArgumentDescription
Open( element )StringOpen Menu.
Close( element )StringClose Menu.
OpenStart = function(){};-To be executed before opening Menu.
CloseEnd = function(){};-To be executed after closing Menu.
CloseStart = function(){};-To be executed before opening Menu.
CloseEnd = function(){};-To be executed after closing Menu.

Demo

https://frontend-isobar-jp.github.io/mgn-menu/

import mgnMenu from 'mgn-menu';

let menu = new mgnMenu(
    ".j-menu",
    {
        globalNav: "#gNav",
        activeName: "open",
        closePoint: 768,
        noScroll: false
    }
);

menu.Open();

setTimeout(function() {

    menu.Close();

},1000);

menu.OpenStart = function() {
    console.log("openStart")
}
menu.OpenEnd = function() {
    console.log("openEnd")
}
menu.CloseStart = function() {
    console.log("closeStart")
}
menu.CloseEnd = function() {
    console.log("closeEnd")
}