BySlideMenu - Nice and powerful accordion menu
What is BySlideMenu?
BySlideMenu is a plugin for Mootools which allow you to easily create a beautiful accordion menu (sliding menu) on any element you want (ul/li, div, p ...) using images and/or text.
Features
- Works horizontally or vertically.
- Automatic size - The container width/height can be adjusted automatically.
- Menu is expandable by mouseover or by click, as you want.
- Menu can be pinned or not, by mouseover or click, you choose.
- A default index can be defined.
- Can be used with any elements (ul/li, div, p...)
- Overflow support.
Usage
HTML
- <ul id="byslidemenu">
- <li><img src="/demo/BySlideMenu/scripts/picture1.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/picture2.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/picture3.jpg" /></li>
- </ul>
Note: You can use any element you want. Instead of ul / li you can use div / div or div / p ...
Javascript
- var mySlideMenu = new BySlideMenu(container, options);
Container
The ID of the container to transform into sliding menu.
Options
| Option | Type | Default | Description |
|---|---|---|---|
defaultIndex |
int | false |
Index of the element to expand at start. Set to false if none.If you want to expand the third element at start, set defaultIndex to 3. |
expandMode |
string | "mouseover" |
"mouseover": elements will expand on mouse over."click": elements will expand on mouse clic.false: elements will not expand by mouse. |
pinMode |
string | false |
"mouseover": Elements stay opened on mouse over."click": Elements stay opened on mouse click.false: Elements don't stay opened. |
vertical |
bool | false | Set to true to switch in vertical mode. |
compressSize |
int | 40 | The width (or height, in vertical mode) of the elements when "compressed". |
autoSize |
bool | true |
If true, the script will try to detect elements size by checking the first founded image.If false, or if no image is found, the two options below will be used. |
containerWidth |
int | Container width. The width of elements will be automatically calculated from container width. If value is set to "full", then the container width will be its parent's width. |
|
containerHeight |
int | Container height. The height of elements will be automatically calculated from container height. If value is set to "full", then the container height will be its parent's height. |
|
elementWidth |
int | 320 | The width of expanded elements. This option will be used if autoSize is set to false, or if no image is found in menu, and if containerWidth is not defined. |
elementHeight |
int | 240 | The height of expanded elements. This option will be used if autoSize is set to false, or if no image is found in menu, and if containerHeight is not defined. |
useOverflow |
bool | false | If this option is set to true, then overflow will be activated when displaying an element. |
Public method
The
mySlideMenu.expand(index, setDefault) method can be called to expand the indexth element, and pin it if setDefault is true.Requirements
BySlideMenu is written for Mootools v1.2
It requires these modules (and their dependencies):
- Element.Dimensions
- Element.Event
- Fx.Tween
- Fx.Transitions
License
BySlideMenu by ByScripts is licensed under a Open Source MIT License.
Changelog
1.1 beta
+ Possibility to set a container width and/or height, instead of setting the elements width and/or height.
+ Possibility to activate overflow on elements, when displayed.
* Enhancement of the calculation of the elements width/height. Now taking in account the padding and the border width.
0.9 beta
# First release
Examples
Example 1: Default options
HTML
- <ul id="byslidemenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/games.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computer.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></li>
- </ul>
Javascript
- var slideMenu = new BySlideMenu();
Output
Example 2: Same as above, but changing compression width and duration
HTML
- <ul id="compressmenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/games.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computer.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></li>
- </ul>
Javascript
- var compressmenu = new BySlideMenu('compressmenu', {
- compressSize: 10,
- duration: 250
- });
Output
Example 3: Vertical menu
HTML
- <ul id="verticalmenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcardsV.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/gamesV.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computerV.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltowerV.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronicV.jpg" /></li>
- </ul>
Javascript
- var verticalmenu = new BySlideMenu('verticalmenu', {vertical: true});
Output
Example 4: Menu using default index and Bounce transition
HTML
- <div id="indexmenu">
- <p><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></p>
- <p><img src="/demo/BySlideMenu/scripts/games.jpg" /></p>
- <p><img src="/demo/BySlideMenu/scripts/computer.jpg" /></p>
- <p><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></p>
- <p><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></p>
- </div>
Javascript
- var indexmenu = new BySlideMenu('indexmenu', {
- defaultIndex: 4,
- transition: Fx.Transitions.Bounce.easeOut
- });
Output
Example 5: Menu expanded by mouse click
HTML
- <ul id="expandclickmenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/games.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computer.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></li>
- </ul>
Javascript
- var expandclickmenu = new BySlideMenu('expandclickmenu', {expandMode: 'click'});
Output
Example 6: Menu pinned by mouse click
HTML
- <ul id="pinclickmenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/games.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computer.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></li>
- </ul>
Javascript
- var pinclickmenu = new BySlideMenu('pinclickmenu', {pinMode: 'click'});
Output
Example 7: Menu pinned by mouse over
HTML
- <ul id="pinovermenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/games.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computer.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></li>
- </ul>
Javascript
- var pinovermenu = new BySlideMenu('pinovermenu', {pinMode: 'mouseover'});
Output
Example 8: Menu expanded and pinned by mouse click
HTML
- <ul id="clickmenu">
- <li><img src="/demo/BySlideMenu/scripts/creditcards.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/games.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/computer.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/eiffeltower.jpg" /></li>
- <li><img src="/demo/BySlideMenu/scripts/electronic.jpg" /></li>
- </ul>
Javascript
- var clickmenu = new BySlideMenu('clickmenu', {
- expandMode: 'click',
- pinMode: 'click'
- });
Output
Example 9: Text menu
HTML
- <ul id="textmenu">
- <li class="bg1 icon1">Element 1</li>
- <li class="bg2 icon2">Element 2</li>
- <li class="bg1 icon3">Element 3</li>
- <li class="bg2 icon4">Element 4</li>
- <li class="bg1 icon5">Element 5</li>
- <li class="bg2 icon6">Element 6</li>
- <li class="bg1 icon7">Element 7</li>
- <li class="bg2 icon8">Element 8</li>
- <li class="bg1 icon9">Element 9</li>
- </ul>
Javascript
- var textmenu = new BySlideMenu('textmenu', {
- defaultIndex: 1,
- elementHeight: 30,
- elementWidth: 175
- });
Output
Example 10: Vertical text menu with overflow
HTML
- <div id="verticaltextmenu">
- <div class="bg1 first">
- <h5>Title 1</h5>
- <p>This is the first content. Don't you think it's great ?</p>
- </div>
- <div class="bg2">
- <h5>Title 2</h5>
- <p>And now, the second content.</p>
- </div>
- <div class="bg1">
- <h5>Title 3</h5>
- <p>Another one. It may be useful for many things no ?</p>
- </div>
- <div class="bg2">
- <h5>Title 4</h5>
- <p>And the last one... So, what's your opinion on this script ?</p>
- </div>
- </div>
Javascript
- verticaltextmenu = new BySlideMenu('verticaltextmenu', {
- defaultIndex: 1,
- vertical: true,
- elementHeight: 110,
- elementWidth: 200,
- compressSize: 30,
- useOverflow: true
- });
Output
Example 11: Act on menu with links
HTML
- <ul style="font-size: 16pt;">
- <li><a href="javascript:verticaltextmenu.expand(3)">
- Display the third element, but don't pin it.</a></li>
- <li><a href="#" onclick="verticaltextmenu.expand(4, true); return false;">
- Display and pin the fourth element.</a></li>
- </ul>
Output
Example 12 : Setting the container width and height
HTML
- <ul id="fullwidthmenu">
- <li class="bg1 icon1">Element 1</li>
- <li class="bg2 icon2">Element 2</li>
- <li class="bg1 icon3">Element 3</li>
- <li class="bg2 icon4">Element 4</li>
- <li class="bg1 icon5">Element 5</li>
- <li class="bg2 icon6">Element 6</li>
- <li class="bg1 icon7">Element 7</li>
- <li class="bg2 icon8">Element 8</li>
- <li class="bg1 icon9">Element 9</li>
- </ul>
Javascript
- var fullwidthmenu = new BySlideMenu('fullwidthmenu', {
- defaultIndex: 1,
- containerHeight: 30,
- containerWidth: "full"
- });









