Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 964 Bytes

README.md

File metadata and controls

58 lines (39 loc) · 964 Bytes

vue2x-touch

This is a directive wrapper for Hammer.js 2.0

Install

# install dependencies
npm install vue2x-touch --save

Usage

ES6

import Vue2Touch from 'vue2x-touch'
Vue.use(Vue2Touch)

Using the v-touch directive

<a v-touch:tap="callback">Tap me!</a>
<div v-touch:swipe="callback">Swipe me!</div>
<div v-touch:pan="{callback:callback,data:data}">Swipe me!</div>


callback(e,el,data){
	console.log(e)//ev
	console.log(el)//Current Element 
	ocnsole.log(data)//{callback:fn,data:data}
}

Registering Custom Events

// example registering a custom doubletap event.
// the `type` indicates the base recognizer to use from Hammer
// all other options are Hammer recognizer options.
VueTouch.registerCustomEvent('doubletap', {
  type: 'tap',
  taps: 2
})
<a v-touch:doubletap="onDoubleTap"></a>

More Details

See Hammer.js document