项目作者: 746655242

项目描述 :
Touch events plugin for Vue2.js
高级语言: JavaScript
项目地址: git://github.com/746655242/vue2x-touch.git
创建时间: 2017-12-31T15:33:56Z
项目社区:https://github.com/746655242/vue2x-touch

开源协议:

下载


vue2x-touch

This is a directive wrapper for Hammer.js 2.0

Install

  1. # install dependencies
  2. npm install vue2x-touch --save

Usage

ES6

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

Using the v-touch directive

  1. <a v-touch:tap="callback">Tap me!</a>
  2. <div v-touch:swipe="callback">Swipe me!</div>
  3. <div v-touch:pan="{callback:callback,data:data}">Swipe me!</div>
  4. callback(e,el,data){
  5. console.log(e)//ev
  6. console.log(el)//Current Element
  7. ocnsole.log(data)//{callback:fn,data:data}
  8. }

Registering Custom Events

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

More Details

See Hammer.js document