Skip to content

Commit

Permalink
add global config
Browse files Browse the repository at this point in the history
  • Loading branch information
lenvonsam committed Feb 16, 2018
1 parent cf5b497 commit 97661fb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ import Vue2Touch from 'vue2-touch'
Vue.use(Vue2Touch)
```

### Add global Config

``` javascript
Vue.use(Vue2Touch, {
gestures: ['swipe'],
directions: {
swipe: ['swipeleft']
}
})
```
above configurations mean that it can override v-touch gestures which just listens to swipe event and override swipe directions which only listens to swipeleft event.

### Using the v-touch directive

``` html
Expand Down
8 changes: 8 additions & 0 deletions directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ var handler = null
var evtType = ''

const touchs = {
config: function (config) {
if (config.gestures) gestures = config.gestures
if (config.directions) {
for (let k in config.directions) {
directions[k] = config.directions[k]
}
}
},
bind: function(el, binding) {
if (!evt) {
evt = new Hammer.Manager(el)
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import touches from './directive'
const vue2Touch = {
install: function(Vue, options) {
touches.config(options)
Vue.directive('touch', touches)
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue2-touch",
"description": "A directive wrapper Hammerjs for vue2.x",
"version": "1.0.5",
"version": "1.0.6",
"author": "[email protected]",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 97661fb

Please sign in to comment.