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

https://github.com/jounqin/v-touch

A full-featured gesture directive designed for Vue
https://github.com/jounqin/v-touch

Last synced: 3 months ago
JSON representation

A full-featured gesture directive designed for Vue

Awesome Lists containing this project

README

          

# v-touch

[![Greenkeeper badge](https://badges.greenkeeper.io/JounQin/v-touch.svg)](https://greenkeeper.io/)
[![dependencies](https://david-dm.org/JounQin/v-touch.svg)](https://david-dm.org/JounQin/v-touch)
[![devDependency Status](https://david-dm.org/JounQin/v-touch/dev-status.svg)](https://david-dm.org/JounQin/v-touch?type=dev)

A full-featured gesture component designed for Vue

~~__*This module is still working in progress right now, so it is just for placeholder.*__~~

Now, you can try to use `v-touch` in your project!

## Usage

A deadly simply example:

[see this on jsfiddle](https://jsfiddle.net/JounQin/ysvozkLo/)

If you are also working with `vue-touch`, you can use `Vue.use(VTouch, {name: 'move'})` (or something else), so that the directive name will change to `v-move`!

``` js
new Vue({
el: '#app',
template: `


tap: {{ tapNum }},

dblTap: {{ dblTapNum }},

mltTap: {{ mltTapNum }}, lastMltTapped: {{ lastMltTapped }}

press: {{ pressNum }},

swipeLeft: {{ swipeLeftNum }},

swipeRight: {{ swipeRightNum }},

swipeUp: {{ swipeUpNum }},

swipeDown: {{ swipeDownNum }}



{{ msg }}

Just Another Button






toggle x ({{ x }})
toggle y ({{ y }})
`,
data() {
return {
msg: 'try to touch, move, swipe, press me!',
x: false,
y: false,
tapNum: 0,
dblTapNum: 0,
mltTapNum: 0,
lastMltTapped: 0,
pressNum: 0,
swipeLeftNum: 0,
swipeRightNum: 0,
swipeUpNum: 0,
swipeDownNum: 0
}
},
computed: {
touch() {
return {
x: this.x,
y: this.y,
methods: true
}
}
},
methods: {
toggle(prop) {
this[prop] = !this[prop]
},
tap(e) {
this.tapNum++
},
dblTap() {
this.dblTapNum++
},
mltTap({tapped}) {
this.mltTapNum++
this.lastMltTapped = tapped
},
press() {
this.pressNum++
},
swipeLeft() {
this.swipeLeftNum++
},
swipeRight() {
this.swipeRightNum++
},
swipeUp() {
this.swipeUpNum++
},
swipeDown() {
this.swipeDownNum++
},
click() {
console.log('clicked the first button')
},
dblclick() {
console.log('dblclicked the second one')
},
dblclickOuter() {
console.log('dblclicked')
}
}
})
```

## Document

[WIP]