UNPKG

atme-touch

Version:

基于 vue 的 touch 事件组件

36 lines (28 loc) 818 B
import touch from './src/touch.js'; import merge from './utils/merge.js'; let atmeTouch = {}; let defaultConfig = { distance: 30, /* 滑动生效距离 */ duration: 500 /* 长按生效持续时间 */ } atmeTouch.install = (Vue,config) => { if(!config) config = {}; touch.config = merge(config,defaultConfig); Vue.directive('tap',touch); Vue.directive('swipeup',touch); Vue.directive('swipedown',touch); Vue.directive('swipeleft',touch); Vue.directive('swiperight',touch); Vue.directive('longpress',touch); Vue.directive('swipe',touch); Vue.directive('swipestart',touch); Vue.directive('swipeend',touch); Vue.prototype._m = function(f){ let args = Array.prototype.slice.call(arguments,1); return { fn: f, args: args }; } } export default atmeTouch;