Git Product home page Git Product logo

sideout's Introduction

Sideout.js

Demo

Check out the demo to see it in action ( on your browser).

Installation

Also you can use one of many package managers

$ npm install sideout
$ yarn add sideout

Usage

Implementing Sideout.js into your project is easy.

First of all, you'll need to create your markup. You should have a menu (#menu).

<menu id="menu">
  <div>
    <h2> Navigation </h2>
  </div>
</menu>

Add the Sideout.js styles (router.css) in your web application.

body {
  width: 100%;
  height: 100%;
}

.sideout-menu {
  position: absolute;
  left: -264px;
  top: 0;
  z-index: 10;
  width: 264px;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
}

.sideout-open,
.sideout-open body {
  overflow: hidden;
}

Then you just include Sideout.js, create a new instance with some options

<script src="dist/sideout.js"></script>
<script>
  let sideout = new Sideout({
    menu: querySelector('#menu'),
    animation: 'ease',
    duration: 250
  });
  
  // Open
  document.querySelector('.button').addEventListener('click', function() {
    sideout.open();
  });
  
  // Close
  document.querySelector('.button').addEventListener('click', function() {
    sideout.close();
  });
<script>

API

Sideout(options)

Create a new instance of Sideout.

  • options (Object) - Options to customize a new instance of Sideout.
  • options.menu (HTMLElement) - The DOM element that contains your menu application (.sideout-menu).
  • [options.duration] (Number) - The time (milliseconds) to open/close the sideout. Default: 300.
  • [options.animation] (String) - The CSS effect to use when animating the opening and closing of the sideout. Default: cubic-bezier(0.4,0.0,0.2,1). Possible values:
    • ease
    • linear
    • ease-in
    • ease-out
    • ease-in-out
    • step-start
    • step-end
    • cubic-bezier

Sideout.open();

Opens the sideout menu.

sideout.open();

Sideout.close();

Closes the sideout menu.

sideout.close();

Sideout.isOpen();

Returns true if the sideout is currently open, and false if it is closed.

sideout.isOpen(); // true or false

With ❤️ by

License

MIT license. Copyright © 2018 [hexagonhq]

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.