📜 ⬆️ ⬇️

waSlideMenu.js. Multi-level scrolling menu

jQuery plugin that turns a nested (tree) menu into a scrolling menu system.

Repository: github.com/webasyst/waslidemenu
Try it: jsfiddle.net/7LnSY/
Example: demo-.webasyst.com

The task to make such a menu appeared in the process of working on a new design theme for Webasyst applications. As a prototype, we considered navigation menus that can be found on most tablets and smartphones based on iOS, Android, etc. In the web, only one beautiful prototype of the implementation of such a menu was found - in the help center of Facebook . There were no ready-made simple solutions for such a menu, so they wrote their own plugin. Plugin free (MIT) - use on health.

Connection

<link href="/path/to/waslidemenu.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="/path/to/jquery.min.js"></script> <script type="text/javascript" src="/path/to/jquery.waslidemenu.min.js"></script> 

Menu structure

Works on any nested structure regardless of markup: ul li, div, etc.
 <nav id="menu"> <ul> <li> <a href="#1">Parent 1</a> <ul> <li><a href="#1.1">Child 1.1</a> <ul> <li><a href="#1.1.1">We need to go deeper</li> </ul> </li> <li><a href="#1.2">Child 1.2</a></li> </ul> </li> <li><a href="#2">Parent 2</a></li> <li><a href="#2">Parent 3</a></li> </ul> </nav> 

 <nav id="menu"> <div class="menu"> <div class="item"> <a href="#1">1</a> <div class="menu"> <div class="item"><a href="#1.1">1.1</a></div> <div class="item"><a href="#1.2">1.2</a></div> </div> </div> <div class="item"><a href="#2">2</a></div> <div class="item"><a href="#3">3</a></div> </div> </nav> 

Plug-in initialization

Simply:
 $('#menu').waSlideMenu(); 

Or you can add a few settings:
 $('#menu').waSlideMenu({ menuSelector : '.menu', itemSelector : '.item', autoHeightMenu: true, minHeightMenu: 400, backLinkContent: 'Back please', backOnTop: true, scrollToTopSpeed: 200, slideSpeed: 500, onLatestClick: function(){ alert('Last node ' + $(this).text() + ' selected') } }); 

Settings


Callbacks

 $('#menu').waSlideMenu({ onInit : function(){ alert('Here I am!'); }, onLatestClick: function(){ alert('Last node ' + $(this).text() + ' selected') } }); 


Other features and requirements


useful links


Once again: link to the repository and demo . I would be grateful for the feedback and suggestions!

')

Source: https://habr.com/ru/post/221351/


All Articles