Giter Club home page Giter Club logo

js-wipe's Introduction

JSwipe

v 1.0

Swipe Drawer Screenshot

Create a beauty and practical nav drawer (like material drawer) easily

Direct Library Links:

Requirements

material icons and Roboto Font is necessary for the correct functioning. You can view here an live example the gestures only works for mobile devices

Swipe Drawer Screenshot

Use

To begin, we will need include 2 HTML tags in our document, this tags will work as reference for JavaScript.

<span class="__modal_drawer"></span> <!-- 1 -->
<div id="drawer_js"></div> <!-- 2 -->
  1. ( __modal_drawer ) <- semi transparent background than appears when menu is triggered, for lock the background content
  2. ( drawer_js ) <- main content for drawer

Our drawer is initilized with init method, from Drawer and recives an object than contains 2 main nodes, header section named main and items (menu options) section named menu example:

Drawer.init({
  main: // header,
  menu: // menu-items
})

main node must contain an object with the next options:

main: {
  background: 'sources/bg.jpg',        // <- main background path (cover photo)
  photo: 'sources/cobie-smulders.jpg', // <- photo profile path
  title: 'Cobie Smulders',             // <- user name
  subtitle: '[email protected]',           // <- email or user mote
}

menu node recives an object, where each item is defined with the next structure

menu: [{
    icon: 'account circle', // <- define item icon
    label: 'Mi perfil',     // <- define item label
    action: '/profile'      // <- URL route or function
  },{
    separator: 'settings'  // <- separator
  },{
    icon: 'share',
    label: 'Compartir',
    action: share   // <- add pointer to `function share() {...}` it will be executed on click event
}]
  1. icon: recives a String, the name is getted from material icons library
  2. label: recives a String, conatains label for menu item
  3. action: this element can recives a path (URL|route) or a function, for function we pass a reference, without "quotation marks" and () parenthesis, anonymous functions are not supported for now
  4. separator: recives a String used for name a section

Final

Drawer totally configured:

Drawer.init({
  main: {
    background: 'sources/bg.jpg',
    photo: 'sources/cobie-smulders.jpg',
    title: 'Cobi Smulders',
    subtitle: '[email protected]'
  },
  menu: [{
    icon: 'account_circle',
    label: 'Profile',
    action: '/profile'
  },{
    icon: 'favorite',
    label: 'Favorite',
    action: '/favorite'
  },{
    icon: 'share',
    label: 'Share',
    action: share
  },{
    separator: 'settings'
  },{
    icon: 'settings_applications',
    label: 'Settings',
    action: '/settings'
  }]
})

It is posible include a trigger for display the nav drawer, setting the mdrawer_trgger id in any tag of your HTML, example:

<button id="mdrawer_trgger">menú</button>

js-wipe's People

Contributors

e1016 avatar

Forkers

srshark

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.