Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hua1995116/vue-flex-touch

A Vue.js directive both for long press touch on mobile and right click on pc.
https://github.com/hua1995116/vue-flex-touch

directive mobile pc rightclick touch vue

Last synced: about 23 hours ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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
```shell
npm install vue-flex-touch
```

# Usage
```javascript

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

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

// component


I'm flex touch demo


{{flex}}

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

# Examle

## base use

[![Edit Vue Template](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/n0v3orw484?fontsize=14)

## used in chat '@'

[![Edit Vue Template](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/oovv1q83zz?fontsize=14)

# 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 蓝色的秋风