Skip to content

Latest commit

 

History

History
87 lines (59 loc) · 2.14 KB

README.md

File metadata and controls

87 lines (59 loc) · 2.14 KB

vue-flex-touch

A Vue.js directive both for long press touch on mobile and right click on pc

Demo

https://n0v3orw484.codesandbox.io/

Install

npm install vue-flex-touch

Usage

// main
import flexTouch from 'vue-flex-touch'

Vue.use(flexTouch, { timeout: 900 });

// component
<div id="app" v-flex-touch="handleTouch">
  <h1>I'm flex touch demo</h1>
  {{flex}}
</div>


data() {
  return {
    flex: false
  };
},
methods: {
  handleTouch() {
    this.flex = !this.flex;
  }
}

Examle

base use

Edit Vue Template

used in chat '@'

Edit Vue Template

Options

Prop Type default description
timeout number 500(ms) time for long touch. (only mobile)
needSelect boolean false If true, select text
preventDefault boolean true If true, stop default event)

API

vue-flex-touch="handleTouch"

handleTouch(e, type) => void

Arguements:

  • e {Object} event callback
  • type 'touch'|'rightClick' enum type

License

MIT

Copyright (c) 2019 蓝色的秋风