All Projects → tim-soft → use-double-click

tim-soft / use-double-click

Licence: MIT license
🐁 A simple React hook for differentiating single and double clicks on the same component.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to use-double-click

svg-to-swiftui-core
Headless package for converting SVG to SwiftUI
Stars: ✭ 25 (-46.81%)
Mutual labels:  hook
rdfp
This R package connects the DoubleClick for Publishers API from R
Stars: ✭ 16 (-65.96%)
Mutual labels:  doubleclick
ProcessInjector.NET
Learning Process Injection and Hollowing techniques
Stars: ✭ 23 (-51.06%)
Mutual labels:  hook
klyva
A state management library that follows the React component model
Stars: ✭ 53 (+12.77%)
Mutual labels:  hook
storken
🦩 Storken is a React State Manager. Simple as `useState`.
Stars: ✭ 22 (-53.19%)
Mutual labels:  hook
kthook
No description or website provided.
Stars: ✭ 55 (+17.02%)
Mutual labels:  hook
subhook.nim
subhook wrapper for Nim https://github.com/Zeex/subhook
Stars: ✭ 15 (-68.09%)
Mutual labels:  hook
react-ui-hooks
🧩Simple repository of React hooks for building UI components
Stars: ✭ 20 (-57.45%)
Mutual labels:  hook
AndroidSec
记录一些我自己在学习Android逆向过程中的有意思的东西
Stars: ✭ 565 (+1102.13%)
Mutual labels:  hook
hookman
A plugin management system in python to applications (in totally or partially) written in C++.
Stars: ✭ 29 (-38.3%)
Mutual labels:  hook
BaiDuYunCrack
iOS百度云盘 破解速度限制、去广告、去更新 无需越狱~
Stars: ✭ 82 (+74.47%)
Mutual labels:  hook
SwiftLoadHook
Use a hack way to achieve similar functions as Load() or initialize() in OC
Stars: ✭ 21 (-55.32%)
Mutual labels:  hook
ReSift
A state management library for data fetches in React
Stars: ✭ 39 (-17.02%)
Mutual labels:  hook
Uatu
Android方法调用跟踪 ; 方法耗时统计 ; 方法调用参数以及返回值跟踪 ; 方法调用替换;方法hook
Stars: ✭ 93 (+97.87%)
Mutual labels:  hook
isMounted
React hook to check if the component is still mounted
Stars: ✭ 93 (+97.87%)
Mutual labels:  hook
nxdk-rdt
Remote Dev Tool is a tool to remote control an Xbox using memory access and RPC
Stars: ✭ 23 (-51.06%)
Mutual labels:  hook
PEDetour
modify binary Portable Executable to hook its export functions
Stars: ✭ 59 (+25.53%)
Mutual labels:  hook
react-imageViewer
React component for image displaying in full screen
Stars: ✭ 61 (+29.79%)
Mutual labels:  hook
use-change
The most minimalistic React state management library on the market with zero dependencies and React.useState-like syntax
Stars: ✭ 74 (+57.45%)
Mutual labels:  hook
hoox
Functional react state management base on hooks
Stars: ✭ 80 (+70.21%)
Mutual labels:  hook

use-double-click

npm NPM npm bundle size PRs Welcome Codecov Travis (.org)

use-double-click is a simple React hook for differentiating single and double clicks on the same component.

Documentation https://timellenberger.com/libraries/use-double-click

Check out the demo on Codesandbox

What's wrong with onDoubleClick()?

When you double click on an element, onClick() fires twice alongside your single onDoubleClick() callback. This effect isn't desirable when a single click and a double click have different functions!

useDoubleClick() waits within a latency window after a click for a secondary click, and only after this period either the onSingleClick or onDoubleClick() callback will fire a single time.

Install

yarn add use-double-click

Usage

import { useRef } from 'react';
import useDoubleClick from 'use-double-click';

const Button = () => {
  const buttonRef = useRef();
  
  useDoubleClick({
    onSingleClick: e => {
      console.log(e, 'single click');
    },
    onDoubleClick: e => {
      console.log(e, 'double click');
    },
    ref: buttonRef,
    latency: 250
  });
  
  return <button ref={buttonRef}>Click Me</button>
}

Props

Prop Description
onSingleClick A callback function for single click events
onDoubleClick A callback function for double click events
ref Dom node to watch for double clicks
latency The amount of time (in milliseconds) to wait before differentiating a single from a double click

License

MIT © Tim Ellenberger

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].