// initialize modal:
new NVJS_Menu()
// initialize modal with options:
new NVJS_Menu(menuContainer, parameters, logErrors);menuContainer- string (with CSS Selector) of NVJS_Menu container HTML element. Optional. On default use'.header';parameters- object with NVJS parameters. Optional;logErrors- boolean - which allow to log all Errors and Warnings in console, if it'strue. Optional. On defaultfalse.
example:
new NVJS_Menu({
menuShowButtons: '.hamburger',
menu: '.header__menu'
})
menuShowButtons
Used for settoggle menuon click this elements. May be string (with CSS Selector) or Array of strings (with CSS Selector)
typeStringorArray
default'.hamburger'
menu
String with toggling menu CSS Selector
typeString
default'.header__menu'
menuOpenClass
CSS class name added to header elements when it becomes opened
typeString
default'open'
autoInitialize
Whether NVJS_Menu should be initialised automatically when you create an instance. If disabled, then you need to init it manually by calling myMenu.initialize()
typeBoolean
defaulttrue
lockBody
If enable, you can't scroll body, while menu is openned
typeBoolean
defaulttrue
on
Register and control event handlers
typeObject
default{}
List of events avaliable bellow in paragraph 'Events'
example:
new NVJS_Menu({
on: {
toggle: () => {
console.log('toggle')
},
scroll: {
'someKey': 'anyValue',
callingFunction: () => {
console.log('scroll')
}
},
}
}); toggle and scroll - event names. Event Values May be:
boolean- if true, events will dispatchfunction- events will dispatch and function will call, when event sendobject- events will dispatch and event may me configurated
enable
If enable, events will dispatch
typeBoolean
addClass
If enable, activeClass will add to the header
typeBoolean
activeClass
CSS class name added to header when the event happened
typestring
callingFunction
JS function called when the event happened
typeBoolean
elements
Used for settoggle menuon click this elements. May be string with'header','menuShowButtons'``, 'menu'or Array of strings. Last param in Array may be array with CSS selectors.
typeStringorArray
avaliable'header','menuShowButtons'``, 'menu'andArraywith CSS selectors
default['header', 'menuShowButtons', 'menu']
sensivity
Count of pixels which user must scrolled in 300ms to 'scrolled' event happend
avaliable'low'(40),'medium'(20),'high'(0) orNumber
defaultmedium
example:
let myMenu = new NVJS_Menu();
myMenu.open()
.initialize();
Initialize NVJS_Menu if autoinitialize false in config
.toggle();
Hide menu menu if it was open and conversely
.hide();
Hide menu
.show();
Open menu
.header;
Header Element
- Using
onparameter on initialization: example:
new NVJS_Menu({
on: {
toggle: () => {
console.log('toggle')
},
scroll: () => {
console.log('scroll')
}
}
});- Using
onparameter on initialization, if you want config events: example:
new NVJS_Menu({
on: {
toggle: {
'someKey': 'anyValue',
callingFunction: () => {
console.log('toggle')
}
},
scroll: {
'someKey': 'anyValue',
callingFunction: () => {
console.log('scroll')
}
},
}
}); - Using
onparameter after initialization: example:
let myMenu = new NVJS_Menu();
myMenu.on('ready', () => {
console.log('ready')
})
ready
When modal ready, but not set Events and wait initialization
initialize
When modal initialized
open
When menu is open
hide
When menu is hide
scroll
When menu scroll
scrollToTop
When menu scroll to top
scrollToBottom
When menu scroll to bottom