Giter Club home page Giter Club logo

off-canvas's Introduction

Off-Canvas not maintained

Deprecated: This project is no longer maintained.


This is a Sassy JavaScript library for off-canvas content. Install it with Bower:

$ bower install --save off-canvas

Markup

Required and optional classes you should use. The oc namespace can be changed by editing the $off-canvas-namespace Sass variable and passing that same value as an option when initializing Off-Canvas.

<body class="oc">
  <a class="oc-toggle" href="#">
    <!-- toggles the off-canvas menu -->
    <!-- you can have multiple of these -->
    <!-- for example a close button in the off-canvas menu -->
  </a>

  <ul class="oc-menu">
    <!-- mobile navigation or what have you -->
  </ul>

  <div class="oc-fixed">
    <!-- a fixed element which should stay outside .oc-content -->
    <!-- usually the good ol' desktop navigation -->
  </div>

  <div class="oc-visible">
    <!-- visible until the breakpoint -->
  </div>

  <div class="oc-hidden">
    <!-- hidden until the breakpoint -->
  </div>

  <div class="oc-content">
    <!-- pushed away when the menu opens -->

    <div class="oc-overlay-container">
      <!-- where the overlay will be appended (optional) -->
      <!-- if omitted, .oc-content will be used -->
    </div>
  </div>
</body>

Styles

The default configuration:

// prefix of your classes, for example .oc-menu
$oc-namespace:            "oc" !default;

// display style of the menu, more styles coming soon...
$oc-style:                normal !default;

// z-index of the menu, sometimes necessary
$oc-zindex:               100 !default;

// position of the menu
$oc-position:             top !default;

// width of the menu, if the position is
// top or bottom, leave this at auto
$oc-width:                auto !default;

// height of the menu, if the position is
// left or right, leave this at auto
$oc-height:               auto !default;

// animation duration of opening the menu
$oc-transition-duration:  .2s !default;

// at which point the menu activates or deactivates
$oc-breakpoint:           to 480px !default;

// whether an overlay will appear,
// which the user can click to close the menu
$oc-overlay:              true !default;

Initialization

When you're done configuring:

var offCanvas = new OffCanvas({
  // sets the namespace of the classes
  // (optional, defaults to 'oc')
  namespace: 'oc',

  // callback when the menu opens
  // (optional)
  onOpen: function() { /* ... */ },

  // callback when the menu closes
  // (optional)
  onClose: function() { /* ... */ }
});

// closes the menu if it's open
// opens it if it's closed
offCanvas.toggle();

// opens the menu
offCanvas.open();

// closes the menu
offCanvas.close();

off-canvas's People

Contributors

silvenon avatar

Stargazers

 avatar Elias Eldabbagh avatar

Watchers

 avatar James Cloos avatar Ante Matijaca avatar

Forkers

teamtriad kimil

off-canvas's Issues

Accessibility

Maybe make all off-canvas-hidden stuff .sr-only and give the off-canvas-menu aria-hidden="true"?

Make menu fixed

position: fixed apparently prevents the horizontal scrollbar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.