npm.io
1.4.1 • Published 3 years ago

@manuelernestog/click-handler

Licence
MIT
Version
1.4.1
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
3

manuelernestog/click-handler

npm (scoped) npm bundle size (minified)

Handle click and dblclick events on same element on javascript.

Install

$ npm install @manuelernestog/click-handler
// or
$ yarn add @manuelernestog/click-handler

Usage

import ClickHandler from("@manuelernestog/click-handler");

const clickDelay = 500; // delay it's optional (350 miliseconds by default)
var clickHandler = new ClickHandler(clickDelay);

function onClickActions() {...}
function onDblClickActions() {...}

// Call the handle method inside your click action
function onClick() {

    clickHandler.handle(onClickActions,onDblClickActions);

    // If you need to handle this behavior in different elements in the same view, add the ID for isolating the state of each element
 clickHandler.handle(onClickActions,onDblClickActions,elementId);

}

Keywords