Skip to content

A Vue directive to distinguish between click and double click

License

Notifications You must be signed in to change notification settings

huangshuwei/vue-click-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-click-helper

Vue2.x directive to handle click event and dblclick event on same element

Introduction

By default, two click interval of less than 300 ms will execute double click event, otherwise click events will execute click event

Installation

npm i vue-click-helper -D

Basic Usage

<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...
                }
            }
    }

}

Advanced

If you want to set, execute double click within 290 milliseconds,just:

<template>
    <div v-click-helper:290="clickHelper">click me</div>
</template>

License

http://www.opensource.org/licenses/mit-license.php

About

A Vue directive to distinguish between click and double click

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published