From the HTML (see the full code) you will see two elements: the menu icon wrapper which will be visible in mobile mode, and the menu.
<div class="menu-icon-wrapper">
<div class="menu-icon" data-menu="mcmenu">
...
</div>
</div>
<div id="mcmenu">
<ul>....</ul>
</div>
Note:
<li class="full-width">...<div class="dropdown">...</div></li>
<li>...<ul class="dropdown">...</ul></li>
Note:
Open mcmenu.js from the downloaded files and adjust the options to fit your needs:
var mcmenuOptions =
{
menuId: "mcmenu",
open: "onmouseover", //or "onclick"
delay: 90,
mobileBreakpoint: 500,
breakpointMode: 1,
multirow: null,
mobileDropdownDirection: 1,
linkIdToMenuHtml: null,
topItemAnimation: "1, 0.5, ease"
};
var mcmenu = new McMenu(mcmenuOptions);
......
McMenu initializes when the page loads. If the menu markup is added later, initialize ddmenu using one of two methods:
var mcmenu = new McMenu(mcmenuOptions);
Then, add this line at the appropriate place in your code—such as inside a fetch callback—when you want to initialize the menu.
mcmenu.rebuild();
The menu id specified in the HTML markup:<div id="mcmenu">...</div>
Ways to open sub-menu dropdown:
either "onmouseover" or "onclick".
The menu will turn to mobile mode if the width is or less than this breakpoint.
Please refer to next property, breakpointMode, to see what the width means.
Value:Specify what the mobileBreakpoint width refers to.
It has three possible values: 1, 2, or 3.
Option 1 is the most commonly used. Option 3 is demonstrated in the example on this page.
Note: Be sure to have the following code in the head section of your page:<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Otherwise, the script may not correctly detect the browser width on mobile devices.
You can insert a breakpoint between desktop and mobile phone.
Its value can be:
*The Width mentioned above: Please refer to the previous property breakpointMode.
Configures the sliding direction when sub-menu(dropdown) is opening in mobile mode. Its value options:
Specifies the animation effect for the top-level links in mobile mode.
Leave this box blank if you don't need animations for the top-level links.
Its value format: Animation order, duration, timing-function