Giter VIP home page Giter VIP logo

vue-gesture's Introduction

http://localhost:8080/example.html

vue-gesture

gesture events plugin for Vue.js.You can v-gesture directive,and directive auguments can use a tap, swipe, touchstart etc.When you are in the use of the PC,"tap, longtap, touchstart" Will automatically be converted to "click".

  • tap — fires when the element is tapped.
  • doubleTap — this pair of events can be used to detect double taps on the same element
  • longTap — fires when an element is tapped and the finger is held down for more than 750ms.
  • swipe, swipeLeft, swipeRight, swipeUp, swipeDown — fires when an element is swiped
  • touchstart touchmove touchend click- These equivalent to touch the primary event

Install

CommonJS

  • Available through npm as vue-gesture.

    var VueGesture = require('vue-gesture')
    Vue.use(VueGesture)

Direct include

  • You can also directly include it with a <script> tag when you have Vue already included globally. It will automatically install itself, and will add a global vueGesture.

Usage

Using the v-gesture directive

<div v-gesture:touchstart.stop.prevent="handle($event, 'touchstart')">touchstart</div>
<div v-gesture:touchmove="handle($event, 'touchmove')">touchmove</div>
<div v-gesture:touchend.stop.prevent="handle($event, 'touchend')">touchend</div>
<div v-gesture:tap.stop.prevent="handle($event, 'tap')">tap</div>
<div v-gesture:doubletap.stop.prevent="handle($event, 'doubleTap')">doubleTap</div>
<div v-gesture:longTap.stop.prevent="handle($event, 'longTap')">longTap</div>
<div v-gesture:swipe="handle($event, 'swipe')">swipe</div>
<div v-gesture:swipeLeft="handle($event, 'swipeLeft')">swipeLeft</div>
<div v-gesture:swipeRight="handle($event, 'swipeRight')">swipeRight</div>
<div v-gesture:swipeUp="handle($event, 'swipeUp')">swipeUp</div>
<div v-gesture:swipeDown="handle($event, 'swipeDown')">swipeDown</div>

Configuring Recognizer Options

There are two ways to customize recognizer options such as direction and threshold. The first one is setting global options:

// change the config
vueGesture.config = {
  maxSingleTapTimeInterval: 200
}

Registering Custom Events

See /example for a multi-event demo. To build it, run npm install && npm run build.

License

MIT

vue-gesture's People

Contributors

mlyknown avatar

Watchers

James Cloos avatar guomin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.