GithubHelp home page GithubHelp logo

hjl19911127 / vue-drawer-layout Goto Github PK

View Code? Open in Web Editor NEW
410.0 10.0 87.0 22.97 MB

A simple DrawerLayout component for Vue.js.

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

License: MIT License

JavaScript 84.58% Vue 15.17% HTML 0.26%
vue vue-drawer-layout commonjs drawerlayout sidebar drawer drag drawerlayout-component android

vue-drawer-layout's Introduction

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

Name Info Type Default
drawer-width width of drawer(px) Number 80% of the container(parentNode) width
drawable-distance farthest distance to draw(px) Number same as drawer-width prop
z-index z-index of drawer Number 818(Don't Ask^_^)
content-drawable whether to make content-wrapper drawable Boolean false
backdrop whether to show backdrop Boolean true
backdrop-opacity-range the opacity range of backdrop[min,max] Array [0,0.4]
enable is drawer enable Boolean true
animatable is drawer animate during moving Boolean true
reverse is drawer slide out from right Boolean false

Slots

Name Info
drawer content in drawer-content
content content in main-content

Methods

Name Info Arguments Usage
toggle method to show and hide drawer visible(Boolean) toggle(true/false) or toggle()to show(hide)

Events

Name Info Callback Arguments
slide-start drawer start to slide (fired when touchdown) -
slide-move drawer sliding (fired when touchmove) pos(int)
slide-end drawer sliding (fired when touchend or transitionend) visible(boolean)
mask-click touch(click) on mask -

License

MIT License.

Copyright (c) 2018 Alexander Huang.

vue-drawer-layout's People

Contributors

hjl19911127 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-drawer-layout's Issues

滑动问题

微信内置浏览器 content内容上下滑动在iphone上不能滑动,Android没问题,这个问题不兼容么,有没有什么好的解决方法呢?

作者您好,有个问题询问下,我点击抽屉部分任何区域就会触发handleToggleDrawer,隐藏了抽屉页面

主要是设置了抽屉页面的样式后点击任何区域都会隐藏抽屉页面。
代码是仿照的http://share.codehuang.com/vue-drawer-layout
这个里面的Methods一项,具体代码如下:
template部分代码:


<div class="drawerList" @click="handleToggleDrawer">
<a @click="handleToggleDrawer">Hide Drawer






JavaScript代码:
methods: {
handleToggleDrawer() {
this.$refs.drawerLayout.toggle();
}
}
css代码:

<style lang="stylus" scoped> .drawer .drawerList position: absolute overflow: hidden top: 0 left: 0 width: 95% height: 100% background: #ffffff .content </style>

微信内置浏览器无法使用

在谷歌浏览器及其手机模拟模式可以使用,但是在微信浏览器中无法使用
经排查发现是无法正确识别微信浏览器
解决方案:
helper.jssupportsTouchDetector函数添加是否是微信浏览器的判断

export const supportsTouchDetector = cacheFunctionWrapper(() =>('ontouchstart' in window)||(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)=="micromessenger"));

Option to swipe from bottom?

It would be great if you could to create an option to set the swipe action from the bottom to get a drawer like maps on iOS. I taked a look to the code but for me it's a little bit complicated.

content里面的list无法滑动

<vue-drawer-layout
  ref="drawer"
  :drawer-width="800">
  <div class="drawer-content" slot="drawer">
      <home-navigationbar></home-navigationbar>
  </div>
  <div slot="content">
    <router-view ></router-view>
  </div>
</vue-drawer-layout>

延迟问题

在ios最新版手机qq和uc上,点击handleToggleDrawer方法会有0.5-1s的延迟触发,在微信和Safari没问题,很奇怪

关于refresh

在设备切换时候,drawer 宽度不变,又或者在不同设备下去开启或者关闭drawer,drawer 保持不变 ,建议暴露一个refresh方法

Default scroll not working

是否有办法不在content内部滚动。
浏览器整屏截图功能 eventListener('scroll') 都会在此滚动方式下失效

Style conflict with Bulma in Tabs

The bottom border of the first item is still visible while it is selected. It only conflicts with the first item. I was working with Buefy which is based on Bulma. So I tested with both Bulma and Buefy tab component. See the attached image.

screenshot from 2019-02-17 12-18-26

Disable drawer open on swipe

I have a horizontal scrollable list in my content and whenever I swipe to scroll the list the drawer opens.
Is there a way for me to make drawer open only when I call its toggle method

Are we missing some css

Not sure if i am missing something. But it seems as if the content isn't scrollable. Are we missing come css for this?

not working with NUXT

{ TypeError: Cannot read property 'middleware' of undefined
at module.exports.webpack_exports.default (.nuxt/server.js:115:0)
at process._tickCallback (internal/process/next_tick.js:68:7) statusCode: 500, name: 'TypeError' }

Doesn't work on window resize

Hi,
when you switch from portrait to landscape, you can't drag anymore.
Maybe you should add a resize event to retrigger calculations on window resize?

Thanks.

该组件导致无法页面滚动?

在未使用您的框架下

<template>
  <div id="drawer">
    <navbar @childEvent="handleToggleDrawer"></navbar>
    <slot></slot>
    <toolbar></toolbar>
  </div>
</template>

该可以将长页面拉到最底层

而在使用您的框架时

<vue-drawer-layout ref="drawerLayout">
    <div class="drawer" slot="drawer">
      <navbar-list></navbar-list>
    </div>
    <div class="content" slot="content">
      <navbar @childEvent="handleToggleDrawer"></navbar>
      <slot></slot>
      <toolbar></toolbar>
    </div>
</vue-drawer-layout>

在content元素过长时候无法进行页面滚动,而我并没有办法解决这个问题

Option to enable or disable dragging

Is there any way to switch the dragging? If not, can you please give a thought about it? Cause there are situations when I don't want the drawer to be revealed by dragging other than mouse click. It would be a great help.

Conflict with vue awesome swiper/swiperjs

Is there anyway of adding a no swiping area?

I have an internal slideshow using vue awesome swiper/swiperjs and swiping this causes the sidebar to open (on a touch friendly device only as far as I am aware).

This has only happened since I upgraded vue awesome swiper/swiperjs but adding a no swiping class or area would fix this issue.

Vue 3?

Thanks for a perfect library! Any chance that you will upgrade it for Vue 3 maybe?

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.