Skip to content

JCharante/vue-long-press-directive

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-long-press-directive

Long press directive plugin for Vue.js. See the live demo (default setting of 2000ms).

npm install @jcharante/vue-long-press-directive

Usage

Register the plugin with Vue. It's possible to specify the press duration in the options object.

var Vue = require('vue')
var longpress = require('@jcharante/vue-long-press-directive')

Vue.use(longpress, { duration: 1000 })

The directive can now be used in a template.

<button v-long-press='onlongpress'>Press and hold</button>

If you want to pass arguments, you're going to need to wrap the function so it doesn't get called immediately.

<button v-long-press="(() => { onlongpress(1) })">Button 1</button>
<button v-long-press="(() => { onlongpress(2) })">Button 2</button>

DO NOT DO

<button v-long-press="onlongpress(1)">Button 1</button>

because your function will get called a bunch of times without being long pressed.

About

Long press directive plugin for Vue.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.6%
  • Vue 6.4%