Vue2.x directive to handle click event and dblclick event on same element
By default, two click interval of less than 300 ms will execute double click event, otherwise click events will execute click event
npm i vue-click-helper -D
<template>
<div v-click-helper="clickHelper">click me</div>
</template>
import Vue from 'vue'
import vueClickHelper from 'vue-click-helper'
export default{
directives: {
'click-helper': vueClickHelper
},
methods:{
clickHelper(e,isDoubleClick){
if (isDoubleClick){
// execute double click logic...
}else{
// execute normal click logic...
}
}
}
}
If you want to set, execute double click within 290 milliseconds,just:
<template>
<div v-click-helper:290="clickHelper">click me</div>
</template>