jQuery Offcanvas
jQuery Offcanvas is the easy way to arrange overloaded websites or to design user-friendly mobile navigations.
Set oversized content as off-canvas and let it flow-in, if needed - simple.
Take a look at the project page to see full documentation.
Features
- Completely responsive
- Built-in touch/swipe support
- Control of the entire behavior with lots of options
- Fall-back for non-javascript users (will just don't do anything)
- Lightweight - both, CSS and JS, just ~??? KB (minified and gzipped)
Setup
1. Link files
Include jquery.offcanvas.min.js and jquery.offcanvas.min.css after the jQuery library.
2. Identify main canvas
It's required to set a main canvas. By default it's #page
. You can wrap the whole page with div#page
or set the main canvas selector via mainCanvas
. Important: It's not allowed to set body
as main canvas.
;
3. Initialization and usage
After initialization, call a public method like show
, hide
or toggle
.
;
Dependencies
jQuery Offcanvas requires jQuery 1.7.0+. Certainly, it works with jQuery 2.x as well.
It is not necessary, but the animations are much smoother with the newest version of jQuery Transit.
Options
To see the full documentation, go to the project page. These are the default options:
defaults =/* Off-canvas */position: 'left' // top|right|bottom|leftmode: 'push' // push|cover|baseinjectPosition: 'before' // before|after, relative to main canvascloneElement: false // Instead of moving itwidth: '100%' // <length>, <percentage>height: '100%' // <length>, <percentage>jsFallback: true // If browser doesn't support CSS3 transitions or Transit isn't availableanimate: {} // Add further [animation](http://api.jquery.com/animate/) properties/options/* Main canvas */mainCanvas: '#page' // Selector or jQuery objectmainCanvasClick: true // Make the main canvas click-ablemainCanvasAnimate: {} // Add further [animation](http://api.jquery.com/animate/) properties/options - Overwrites 'animate'mainCanvasCss: {} // Add CSS styles to the main canvas/* Callbacks */{} // Triggered before the off-canvas is shown{} // Triggered after the off-canvas is shown{} // Triggered before the off-canvas is hidden{} // Triggered after the off-canvas is hidden{} // Triggered after clicking on the main canvas;
Release notes
Each major release is mostly backward-compatible. See the history to see all changes and fixes.
Support
Found some issues? Create and issue with the issue tracker.
License
jQuery Offcanvas is released under the MIT license