@nanogiants/vue3-longpress

This package contains a Vue 3 directive which adds the `@longpress` event to an element.
2,241 2
Install
npm install @nanogiants/vue3-longpress
Latest Version:1.0.8
License:MIT
Last Updated:Aug 16, 2023
Links: GitHub  ·  npm
Maintainer: nanogiantsadmin

vue3-longpress

This package contains a Vue 3 directive which adds the @longpress event to an element.

Installation

npm i @nanogiants/vue3-longpress
# or
yarn add @nanogiants/vue3-longpress

Usage

// main.ts file
import { vLongpress } from '@nanogiants/vue3-longpress';
import App from './App.vue';

const app = createApp(App);
app.directive('use-longpress', vLongpress);


// component.ts
<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

Related Packages

vue3-highlight-text

a vue3 directive of highlight text

84,789
vue-proportion-directive

vue 固定元素比例指令

6,003 10
ardirectives

Ardirectives

811
vue-directive-zery

Vue custom directive extensions, including long press, copy, watermark, permissi...

700
vue-on-click-outside

vue mixin/directive that does something when you click outside a container

169,297 31

Version History

Version Released License
1.0.8 MIT
1.0.7 MIT
1.0.6 MIT
1.0.5 MIT
1.0.4 MIT