vue3-longpress
This package contains a Vue 3 directive which adds the @longpress
event to an element.
Installation
npm i @nanogiants/vue3-longpress
yarn add @nanogiants/vue3-longpress
Usage
import { vLongpress } from 'vue3-longpress';
app.directive('use-longpress', vLongpress);
<template>
<div>
<div v-use-longpress="500" @longpress="onLongpress">Hello World!</div>
<div v-use-longpress @longpress="onLongpress">Hello World!</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
setup() {
const onLongpress = (e: CustomEvent) => {
console.log('onLongpress', e);
};
return { onLongpress };
},
});
</script>
args
There is only one arg you can pass.
The duration can be set as an interger in ms. Default is 500.
<div v-use-longpress="1000" @longpress="onLongpress"></div>
License
MIT