vue-touch-events

extend touch event on vuejs
3,854
Install
npm install vue-touch-events
Latest Version:1.0.3
Vue:2
License:MIT
Last Updated:Apr 12, 2017
Links: npm
Maintainer: yuminjustin

vue-touch-events

This is a plugin for Vuejs, it offer these events
tap,longtap, swipeup,swipedown,swipeleft,swiperight,swipe,drag

Use

 import Touch from 'vue-touch-events'
 Vue.use(Touch)

In Vue component you can bind these touch event just like a normally click event

template

<div>
    <div class="block" v-touch.preventDefault @tap="tapCb" @longtap="longTapCb" @swipeup="swipeupCb" @swipedown="swipedownCb" @swipeleft="swipeleftCb" @swiperight="swiperightCb" @swipe="swipeCb">
        {{msg}}
    </div>
    <div class="block2" v-touch.preventDefault.drag @drag="dragCb">
        {{msg2}}
    </div>
</div>

script

new Vue({
   el: "#app",
   methods: {
	tapCb: ...,
	longTapCb: ...,
	swipeupCb: ...,
	swipedownCb: ...,
	swipeleftCb: ...,
	swiperightCb: ...,
	swipeCb: ...,
	dragCb: ...
  }
}) 

config

preventDefault

Prohibit browser swipe events, just like UC or QQBrowser them has own swipe events, so sometimes we have to prohibit. Default is not prohibit

drag

This dom can be dragged ,default is can't. Drag event can't coexist with other touch events



run this example

npm install	

install webpack and Vue

npm run dev

open index.html in your browser

install in you project

npm install vue-touch-events -S

SSR

if (process.BROWSER_BUILD) {
  Vue.use(require('vue-touch-events'));
}

use it only in browser

Related Packages

vue3-photo-hammer-mixture

图片拖动-缩放-旋转-并与底图进行截图合成

402
vue3-hand-mobile

Vue mobile gesture action event.

5,464
vue-drag-handle

a touch handle to drag something

1,187 1
vue3-touch-events

Simple touch events support for vue.js 3

3,210,829 344
vue2-touch-events

Simple touch events support for vueJS2

1,398,605 540

Version History

Version Released Vue License
1.0.3 ^2.2.6 MIT
1.0.2 ^2.2.6 MIT
1.0.1 ^2.2.6 MIT
1.0.0 ^2.2.6 MIT