A Vue.js directive both for long press touch on mobile and right click on pc
https://n0v3orw484.codesandbox.io/
npm install vue-flex-touch
// 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;
}
}
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) |
vue-flex-touch="handleTouch"
handleTouch(e, type) => void
Arguements:
- e
{Object}
event callback - type
'touch'|'rightClick'
enum type
MIT
Copyright (c) 2019 蓝色的秋风