Code Monkey home page Code Monkey logo

vue2-hammer's Introduction

vue-hammer

Hammer.js wrapper for Vue to support some operation in the mobile

This is a directive wrapper for Hammer.js 2.x. And this repo'inspiration is from v-touch.

Install

This plugin supports Vue >= 2.0.

npm

Available through npm as vue2-hammer.

npm install vue2-hammer
import { VueHammer } from 'vue2-hammer'
Vue.use(VueHammer)

Usage

Using the v-hammer directive

<a v-hammer:tap="onTap">Tap me!</a>

<div v-hammer:swipe.left="onSwipeLeft">Swipe me!</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 threshold for all swipe recognizers
VueHammer.config.swipe = {
  threshold: 200
}
<a v-hammer:doubletap="onDoubleTap"></a>

See Hammer.js documentation for all available events.

Supported gesrtures and directions

gestures

tap, pan, pinch, press, rotate, swipe, doubletap

directions

up, down, left, right, horizontal, vertical, all

Note

Users can use both the gesture and the direction like v-hammer:swipe.left. But if your combination is not exist in the hammer, it is not support.

Run the Example

  • Run yarn or npm i
  • Run yarn build or npm run build
  • Open the index.html in the example directory.

License

MIT

vue2-hammer's People

Contributors

bsdfzzzy avatar gvdp avatar

Watchers

James Cloos avatar Sebastian Gabbert 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.