A touch slideout navigation menu for your web apps.
Check out the demo to see it in action (on mobile or emulate touches on your browser).
http://i.imgur.com/B3owSlI.gif
$ npm install slideout
$ bower install slideout
$ component install mango/slideout
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="cleartype" content="on">
<meta name="MobileOptimized" content="320">
<meta name="HandheldFriendly" content="True">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Slideout Demo</title>
</head>
<body>
<nav id="menu" class="slideout-menu">
<header>
<h2>Menu</h2>
</header>
</nav>
<main id="main" class="slideout-panel">
<header>
<button class="btn js-slideout-toggle">☰</button>
<h2>Panel</h2>
</header>
</main>
<script src="slideout.js"></script>
</body>
</html>
You should add the following CSS in your application.
html,
body {
width: 100%;
height: 100%;
}
.slideout-menu {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 0;
width: 256px;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
display: none;
}
.slideout-panel {
position: relative;
z-index: 1;
transform: translate3d(0, 0, 0);
}
.slideout-open,
.slideout-open body {
overflow: hidden;
}
.slideout-open .slideout-menu {
display: block;
}
var slideout = new Slideout({
'panel': document.getElementById('main'),
'padding': 256,
'tolerance': 70
});
Create a new instance of Slideout
.
options
(Object) - Options to customize a new instance of Slideout.options.panel
(HTMLElement) - The DOM element that contains all your application content (.slideout-panel
).[options.duration]
(Number) - The time (milliseconds) to open/close the slideout. Default:300
.[options.fx]
(String) - The CSS effect to use when animating the opening and closing of the slideout. Default:ease
.[options.padding]
(Number) - Default:256
.[options.tolerance]
(Number) - Default:70
.
Opens the slideout menu.
slideout.open();
Closes the slideout menu.
slideout.close();
Toggles (open/close) the slideout menu.
slideout.toggle();
Returns true
if the slideout is currently open, and false
if it is closed.
slideout.isOpen(); // true or false
$ npm run build
$ npm run dist
$ npm test [TODO]
- Guille Paz (Front-end developer | Web standards lover)
- E-mail: [email protected]
- Twitter: @pazguille
- Web: http://pazguille.me
MIT license. Copyright © 2015 Mango.