1.3.0 • Published 5 years ago

vue-drawer-layout v1.3.0

Weekly downloads
326
License
MIT
Repository
github
Last release
5 years ago

vue-drawer-layout

npm npm travis npm npm

A simple DrawerLayout component for Vue.js

中文文档

Demo

http://share.codehuang.com/vue-drawer-layout

Mobile QQ by Alexander Huang(click me or scan the qrcode)

Try it

Click the avatar at the top-left or touch(click) and drag to right(left).

Demo

If the image is not animating, maybe your browser does not supports APNG, you could turn to the GIF demo.

Dependencies

Browser Support

Modern (mobile) browsers and Internet Explorer 10+(due to CSS transition support) and X5 core is supported.

Installation

npm install vue-drawer-layout --save

Usage

The following examples can also be used with CommonJS by replacing ES6-specific syntax with CommonJS equivalents.

import Vue from 'vue'
import DrawerLayout from 'vue-drawer-layout'

Vue.use(DrawerLayout)
// or
import {DrawerLayout} from 'vue-drawer-layout'
Vue.component(DrawerLayout.name, DrawerLayout)

You can easily just set nothing or only drawer-width prop to get a simple drawer.It act above the main content.

<vue-drawer-layout ref="drawer" :drawer-width="800">
  <div class="drawer-content" slot="drawer">
    <!-- drawer-content -->
  </div>
  <div slot="content">
    <!-- main-content -->
  </div>
</vue-drawer-layout>

Or you can set every prop as you want to get a fantastic drawer like mobile QQ has(It act below the main content and with distance is 1/3 of the main content drag).

<vue-drawer-layout
  ref="drawer"
  :drawer-width="800"
  :enable="true"
  :animatable="true"
  :z-index="0"
  :drawable-distance="Math.floor(800/3)"
  :content-drawable="true"
  :backdrop="true"
  :backdrop-opacity-range="[0,0.4]"
  @slide-start="handleSlideStart"
  @slide-move="handleSlideMove"
  @slide-end="handleSlideEnd"
  @mask-click="handleMaskClick">
    <div class="drawer-content" slot="drawer">
      <!-- drawer-content -->
    </div>
    <div slot="content">
      <!-- main-content -->
    </div>
</vue-drawer-layout>

API

Props

NameInfoTypeDefault
drawer-widthwidth of drawer(px)Number80% of the container(parentNode) width
drawable-distancefarthest distance to draw(px)Numbersame as drawer-width prop
z-indexz-index of drawerNumber818(Don't Ask^_^)
content-drawablewhether to make content-wrapper drawableBooleanfalse
backdropwhether to show backdropBooleantrue
backdrop-opacity-rangethe opacity range of backdropmin,maxArray[0,0.4]
enableis drawer enableBooleantrue
animatableis drawer animate during movingBooleantrue
reverseis drawer slide out from rightBooleanfalse

Slots

NameInfo
drawercontent in drawer-content
contentcontent in main-content

Methods

NameInfoArgumentsUsage
togglemethod to show and hide drawervisible(Boolean)toggle(true/false) or toggle()to show(hide)

Events

NameInfoCallback Arguments
slide-startdrawer start to slide (fired when touchdown)-
slide-movedrawer sliding (fired when touchmove)pos(int)
slide-enddrawer sliding (fired when touchend or transitionend)visible(boolean)
mask-clicktouch(click) on mask-

License

MIT License.

Copyright (c) 2018 Alexander Huang.

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.3

5 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago