File Size: 5976KB
Total Views: 7969
Date Created:
Last Modified Date:
Official Website: Go to website
License: MIT
Slideout.js is very simple and easily customizable jQuery collapsible navigation menu plugin for mobile and web apps. Slideout.js is very lightweight so it can be used without interrupting the performance of any website. It uses very simple markup for the navigation menu so anyone can understand and implement this easily. Totally dependency-free plugin so no need to add any types of external scripts for this.
Features:
- Lightweight, Just 2 Kb! (min & gzip)
- Totally dependency free.
- Very simple markup.
- It uses native scrolling.
- Very easy to customize.
- Supports CSS transforms & transitions.
How to use it:
1. Include the Javascript slideout.min.js
at the bottom of the web page.
<script src="path/to/slideout.min.js"></script>
2. Add the basic HTML to the page.
<nav id="menu">
<header>
<h2>Menu</h2>
</header>
</nav>
<main id="panel">
<header>
<h2>Panel</h2>
</header>
</main>
3. Initialize the plugin and we’re ready to go.
var slideout = new Slideout({
'panel': document.getElementById('panel'),
'menu': document.getElementById('menu'),
'padding': 256,
'tolerance': 70
});
// Toggle button
document.querySelector('.toggle-button').addEventListener('click', function() {
slideout.toggle();
});
4. Add the Slideout.js styles in your web application.
body {
width: 100%;
height: 100%;
}
.slideout-menu {
position: fixed;
top: 0;
bottom: 0;
width: 256px;
min-height: 100vh;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
z-index: 0;
display: none;
}
.slideout-menu-left {
left: 0;
}
.slideout-menu-right {
right: 0;
}
.slideout-panel {
position: relative;
z-index: 1;
will-change: transform;
background-color: #FFF; /* A background-color is required */
min-height: 100vh;
}
.slideout-open,
.slideout-open body,
.slideout-open .slideout-panel {
overflow: hidden;
}
.slideout-open .slideout-menu {
display: block;
}
Plugin’s default options:
Name | Default | Type | Description |
---|---|---|---|
panel |
HTMLElement | The DOM element that contains all your application content (.slideout-panel). | |
menu |
HTMLElement | The DOM element that contains your menu application (.slideout-menu). | |
duration |
300 | Number | The time (milliseconds) to open/close the slideout. |
easing |
ease | String | The CSS effect to use when animating the opening and closing of the slideout. |
padding |
256 | Number | |
tolerance |
70 | Number | The number of px needed for the menu can be opened completely, otherwise it closes. |
touch |
true | Boolean | Set this option to false to disable Slideout touch events. |
side |
left | String | The side to open the slideout (left or right). |
Slideout.open();
Opens the slideout menu. It emits beforeopen and open events.
slideout.open();
Slideout.close();
Closes the slideout menu. It emits beforeclose and close events.
slideout.close();
Slideout.toggle();
Toggles (open/close) the slideout menu.
slideout.toggle();
Slideout.isOpen();
Returns true if the slideout is currently open, and false if it is closed.
slideout.isOpen(); // true or false
Slideout.destroy();
Cleans up the instance so another slideout can be created on the same area.
slideout.destroy();
Slideout.enableTouch();
Enables opening the slideout via touch events.
slideout.enableTouch();
Slideout.disableTouch();
Disables opening the slideout via touch events.
slideout.disableTouch();
Slideout.on(event, listener);
slideout.on('open', function() { ... });
Slideout.once(event, listener);
slideout.once('open', function() { ... });
Slideout.off(event, listener);
slideout.off('open', listener);
Slideout.emit(event, …data);
slideout.emit('open');
Events
beforeclose
close
beforeopen
open
translatestart
translate
translateend
slideout.on('translatestart', function() {
console.log('Start');
});
slideout.on('translate', function(translated) {
console.log('Translate: ' + translated); // 120 in px
});
slideout.on('translateend', function() {
console.log('End');
});
// 'Start'
// 'Translate 120'
// 'End'