Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manuelernestog/click-handler
Handle click and dblclick events on same element on javascript.
https://github.com/manuelernestog/click-handler
Last synced: about 2 months ago
JSON representation
Handle click and dblclick events on same element on javascript.
- Host: GitHub
- URL: https://github.com/manuelernestog/click-handler
- Owner: manuelernestog
- License: mit
- Created: 2022-07-21T15:17:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-30T16:37:39.000Z (over 2 years ago)
- Last Synced: 2024-10-11T01:51:27.386Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- cuban-opensource - click-handler
README
# manuelernestog/click-handler
[![npm (scoped)](https://img.shields.io/npm/v/@bamblehorse/tiny.svg)](https://www.npmjs.com/package/@manuelernestog/click-handler)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/@bamblehorse/tiny.svg)](https://www.npmjs.com/package/@manuelernestog/click-handler)Handle click and dblclick events on same element on javascript.
## Install
```bach
$ npm install @manuelernestog/click-handler
// or
$ yarn add @manuelernestog/click-handler
```## Usage
```js
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);}
```