Install & Download:
# NPM
$ npm install vue-directive-long-press --saveDescription:
A small yet sometimes useful Vue.js directive to detect and handle the long press event on an element.
How to use it:
Import the LongPress.
import LongPress from 'vue-directive-long-press'
Use the directive.
<template>
<button
v-long-press="500"
@long-press-start="onLongPressStart"
@long-press-stop="onLongPressStop">
Click and Hold for 500ms</button>
</template>export default {
directives: {
'long-press': LongPress
},
methods: {
onLongPressStart () {
// do something
},
onLongPressStop () {
// do something
}
}
}Preview: