npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.offcanvas

v3.1.0

Published

The easy way to arrange overloaded websites or to design user-friendly mobile navigations.

Downloads

4

Readme

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.

<script src='jquery.min.js'></script>
<script src='jquery.offcanvas.min.js'></script>
<link rel="stylesheet" href="jquery.offcanvas.min.css" />

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.

$(document).ready(function() {
    $("#offcanvas-box").offcanvas({
        mainCanvas: '#page', // Selector or jQuery object
    });
});

3. Initialization and usage

After initialization, call a public method like show, hide or toggle.

$(document).ready(function() {
    $("#offcanvas-box").offcanvas(/* Pass options as object */); // Initialization

    $("button#toggle").click(function() {
        $("#offcanvas-box").offcanvas("toggle"); // Toggle after click a button
                                                 // Options are bound to the element
    });
});

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|left
    mode:              'push', // push|cover|base
    injectPosition:    'before', // before|after, relative to main canvas
    cloneElement:      false, // Instead of moving it
    width:             '100%', // <length>, <percentage>
    height:            '100%', // <length>, <percentage>
    jsFallback:        true, // If browser doesn't support CSS3 transitions or Transit isn't available
    animate:           {}, // Add further [animation](http://api.jquery.com/animate/) properties/options
    
    /* Main canvas */
    mainCanvas:        '#page', // Selector or jQuery object
    mainCanvasClick:   true, // Make the main canvas click-able
    mainCanvasAnimate: {}, // Add further [animation](http://api.jquery.com/animate/) properties/options - Overwrites 'animate'
    mainCanvasCss:     {}, // Add CSS styles to the main canvas
    
    /* Callbacks */
    onShowBefore:      function() {}, // Triggered before the off-canvas is shown
    onShowAfter:       function() {}, // Triggered after the off-canvas is shown
    onHideBefore:      function() {}, // Triggered before the off-canvas is hidden
    onHideAfter:       function() {}, // Triggered after the off-canvas is hidden
    onMainCanvasClick: function() {}, // 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