> Slide-in menu
Sometimes the screen of mobile devices is too small to fit all the controls, menus and options of your application. One solution is to create a slide in menu that the user can pull to access additional functions.

Project info
Last code update: 2010.05.28 – v0.1 beta 1
Device compatibility: iPhone/Ipod touch >=2.0, Android >1.6, iPad.
QR Code opens demo page. (On Android you may need to refresh the page once loaded, I’m looking into this issue with QR links).
Support development
If this script saved your day or you wish to support future developments you may consider sending some funds via PayPal.
Overview
Sometimes the screen of mobile devices is too small to fit all the controls, menus and options of your application. One solution is to create a slide in menu that the user can pull to access additional functions.
The menu is opened both by tapping and pulling the handle.
This widget is ridiculously simple, all it does is to slide in a hidden div on user’s request. Please note that the script is just a draft, I’ll keep developing it if there’s enough interest (see below).
How to use
Initialize the slide in menu on DOMContentLoaded:
menu = new slideInMenu('slidedownmenu');
slidedownmenu is the ID of the element to be slided.
The slider has to be absolutely positioned and the top:
#slidedownmenu {
position:absolute;
width:100%;
height:115px;
top:-115px;
left:0;
z-index:999;
}
The the example I set the top property to -115px so the menu is hidden while the page loads, but it’s not mandatory. The slideInMenu() function takes care of placing the div in the right position.
The handle is positioned to the bottom of the sliding layer. To make it stick out the initially closed menu you just need to set the bottom property equal to the negative value of the handle height:
#slidedownmenu .handle {
-webkit-user-select:none; /* user can't select */
position:absolute;
width:100%;
height:20px;
bottom:-20px;
left:0;
}
Look at the source code of the online demo for details.
Syntax
The function accepts two parameters at startup:
slideInMenu(string ID, bool openAtStartup);
ID is the menu identifier. If you set openAtStartup to TRUE the menu will be in opened when initialized.
You can also open, close and toggle the menu programmatically.
var menu = new slideInMenu('slidedownmenu', true); // Initialize the menu and open it right away
menu.open(); // Open the menu
menu.close(); // Close the menu
menu.toggle(); // Toggle the menu open/close state
Future developments
Add Android compatibilityProgrammatically open/close the menu- Should be possible to place the menu anywhere (ie: slide down/up/left/right)
Revisions history
v0.1 beta 1, 2010.05.28 – Added Android compatibility
v0.1 alpha 1, 2010.05.25 – Initial release
Great plugin, this is really useful. Any suggestions on how to integrate this with jquery mobile?
Hi,
I’m trying to make the bar stay horizontal, however, when “open” it slides left to right.
I like the bar being at the top with a width of 100%, however, I went the menu to fly in from left to right with a height of 100%.
Can you please help?
cool – love your work! simple, solid and useful.
Hello, i feel that i saw you visited my weblog thus i came to return the desire?.I am trying to in finding issues to improve my web site!I guess its adequate to use some of your concepts!!
You may want to take this off the Project State: Active, since there hasn’t been an update in almost 2 years
That said, have you thought about modifying this to handle a 2-row menu (the 2nd row being the “dropdown” for the first) ?
Tom
Is there anyway to change this to make it a slidein-menu from the bottom?
Really awesome, it works fine on Chrome and Safari, too bad it ONLY works there… doesn’t work on IE9, Opera or Firefox.
Good job though.
Meanwhile, this is intended for MOBILE use. Just saying.
This is really awesome, but i have a problem with a android where the website won’t scroll on the mobile page due to the “loaded” function in the file. I take that out and it works fine but obviously the menu bar doesn’t move. How can I fix this, thanks in advance!
Nice! Works properly on blackberry playbook..
It dosen’t work quite well in a web application on iOS 5. It, didn’t worked that well.
When I tried to pull down the menu (full screen web app), well, on iOS 5, the Notification Center slides down first.
Well, there should be a way to move the menu to the bottom, instead.
Great script!
I only have one problem with it though, it’s when you go from portrait to landscape or vise versa. Once you’ve loaded the page in portrait, open the menu and go landscape the elements inside are misplaced as it seems the top/left values are wrongly interpreted. Closing the menu will simply make it go outside the view area and is no longer accessible unless you reload the page. Once you do, however, switching from landscape to portrait works as intended. I believe some sort of rotation detection needs to be added to deal with the element positions!
Any input on this would be highly appreciated as it isn’t very user friendly having to reload the page to bring back the menu / make it work as intended.
Best regards,
Rayken