query.dropSlideMenu.js
dropSlideMenu is my attempt at building a simple (single-level support only), yet easily and highly-customisable drop-down menu with an attractive sliding effect.
query.dropSlideMenu.js v1.0 - View Demo or Download
There are plenty of jQuery drop-down menu scripts already available, but I often find that they're either too basic, or too complicated and bulky, or don't support a proper sliding effect (instead the menus simply change height as they're revealed).
I'm publishing this script with the hope that others might find it useful. Hopefully as it gains popularity, so will the potential for it to improve. Also, I've developed this plugin partly as a jQuery learning exercise. So if you do find yourself downloading and using it, and you're proficient with JavaScript, I would really appreciate if you could spend a minute or two reviewing my code and providing suggestions for improvement.
Features include:
- Requires the mouse cursor to decelerate over the menu before activating, to prevent unintentional opening (big thanks to threedubmedia for their jquery.event.hover plugin)
- Dynamic styling of clickstream (path of links are compared with path of the current URL) - optional
- Possible to set widths on each list item and its drop down
- Possible to individually style each list item and its drop down
- List items with no link behaviour (where href is "#") are disabled
- Settings to control the duration (speed of drop down animation), and delay (before the drop down closes)
- Select elements are hidden (IE6) - optional
- Customisable Easing Effects
- W3C-valid HTML and CSS
To begin, download the source files (.zip) and browse the demo source code to familiarise yourself with the necessary files required, and the way in which they fit together. Assuming you already have the most recent version of jQuery, the JavaScript and CSS files that need to be included in your page are:
<link rel="stylesheet" href="jquery.dropSlideMenu.css" type="text/css" /> <script src="jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script> <script src="jquery.event.hover.js" type="text/javascript"></script> <script src="jquery.dropSlideMenu.js" type="text/javascript"></script>
To attach the plugin to a menu, include the following jQuery script in your page (in this example, #navigation is the menu wrapper):
$(document).ready(function() {
$("#navigation").dropSlideMenu({
indicators: true,
clickstream: true,
openEasing: "easeOutQuad",
closeEasing: "easeInQuad",
duration: 600,
delay: 800,
hideSelects: true
});
});
The settings are fairly self-explanatory. I'm not going to go into more detail as I assume you know what you're doing with jQuery and CSS. If you do require further assistance, please leave a comment below - I can't guarantee that I'll be able to help, but I do make an attempt to reply to all comments.
The most recent version of this plugin will always be the one available for download on this post.
Please let me know if you decide to use it, or have any feedback. Thanks!
- leave a comment
14 Comments
Using the demo, an example of the source code for the menu list after the plugin has executed:
<ul class="ds"> <li><a href="/home">Home</a></li> <li id="dsListItem-1"> <div class="indicator"><a href="/planets">Planets</a></div> <ul id="dsList-1"> <li><a href="/planets/mercury">Mercury</a></li> <li><a href="/planets/venus">Venus</a></li> <li><a href="/planets/earth">Earth</a></li> <li><a href="/planets/mars">Mars</a></li> <li><a href="/planets/jupiter">Jupiter</a></li> <li><a href="/planets/saturn">Saturn</a></li> <li><a href="/planets/uranus">Uranus</a></li> <li><a href="/planets/neptune">Neptune</a></li> </ul> </li> <li id="dsListItem-2" class="clickstream"> <div class="indicator"><a href="/continents">Continents</a></div> <ul id="dsList-2"> <li><a href="/continents/africa">Africa</a></li> <li><a href="/continents/antarctica">Antarctica</a></li> <li><a href="/continents/asia">Asia</a></li> <li><a href="/continents/australia">Australia</a></li> <li class="clickstream"><a href="/continents/europe">Europe</a></li> <li><a href="/continents/north-america">North America</a></li> <li><a href="/continents/south-america">South America</a></li> </ul> </li> <li id="dsListItem-3"> <div class="indicator"><a href="#">Oceans</a></div> <ul id="dsList-3"> <li><a href="/oceans/arctic">Arctic</a></li> <li><a href="/oceans/atlantic">Atlantic</a></li> <li><a href="/oceans/indian">Indian</a></li> <li><a href="/oceans/pacific">Pacific</a></li> <li><a href="/oceans/southern">Southern</a></li> </ul> </li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> <div class="dsClear"> </div> </ul>
Seems like a Chrome 3.0.193.2 issue…
This is really neat, well done.
Wow. Great! :D
I love jQuery♥
[...] Menu – jQuery Plugin Resource: Sample | Tutorial Share and [...]
[...] Sample | Tutorial Share and [...]
This a very well thought out attempt.I find it very practical and useful taking care of the basic logics on which we ever visit a site and wish not to open a list if our cursor even slid over it.This saves a lot of time really!
@Harrison: Thanks, I need to spend more time on it but the basics are there. The hover plugins for jQuery are brilliant, they should be integrated into the core imho as the basic hover functionality is easily abused.
I am interested in the code you use for your forms as beautiful as this, it would be possible to publish it, thanks.
Awesome, JQuery rocks!
didn’t find any problems with the script even in IE6 it was fine. tx
Very nice man! … available for commercial use?
@Steven: expand on “commercial use”? If you plan on selling it, no. Anything else, go wild.
hi from singapore! i was doing my share point project which requires me to get a drop down navigation bar. i really suck in this project. i visited many sites to learn how to get the navigation bar, but still i could not get it and then i came across your site which provide the coolest navigation bar ! thanks man ! 5 THUMBS UP !!
Leave a Comment
Your e-mail address is required, but will not be published.


24 July 2009
David11:29 pm
Hej Damien, I found a small bug.
If you mouseout one of the pulldown items and immediately mouseover again, while the sub menu still’s sliding in, it won’t slide out anymore. Might be not crucial, but still misleading.