Instant mega menus in vanilla JavaScript.
- Keeps a sub-menu open when the mouse is determined to be enroute to it
- Otherwise, instantly switches to another item in the menu list
- 670 bytes gzipped
const menuAim = require('menu-aim')element is a DOM element and optionsis an optional object literal.
-
Returns a “clean up” function for removing event listeners bound by the function to
elementandwindow. -
elementhas the following HTML structure:<ul class="menu-aim"> <li class="menu-aim__item"> <a class="menu-aim__item-name"><!-- ... --></a> <ul class="menu-aim__item-submenu"><!-- ... --></ul> </li> <!-- ... --> </ul>
See the demo for the CSS styles required on
elementand the various nested elements. -
Keys on
options:Key Description Default menuItemSelectorSelector for each menu item. .menu-aim__itemmenuItemActiveClassNameClass name assigned to a menu item when it is active. menu-aim__item--activemenuItemSubMenuSelectorSelector for the sub-menu element nested within each menu item. .menu-aim__item-submenudelayingClassNameClass name applied to elementwhen some menu item is active and the mouse is determined to be enroute to the active submenu.menu-aim--delaying
Install via yarn:
$ yarn add menu-aimOr npm:
$ npm install --save menu-aim