@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
33import { HooksInput } from './types/options' ;
44import { IProps } from './types/props' ;
55
6- const DEFAULT_OPTIONS = { down : false , up : false , touch : true } ;
6+ const DEFAULT_OPTIONS = { down : false , up : false , touch : true , timeout : 10 } ;
77
88/**
99 * Test if a mouse event can trigger a click.
@@ -26,6 +26,7 @@ export const useMouseAction = (options: HooksInput): IProps => {
2626 down,
2727 up,
2828 touch,
29+ timeout,
2930 onClick,
3031 onMouseDown,
3132 onMouseUp,
@@ -52,7 +53,7 @@ export const useMouseAction = (options: HooksInput): IProps => {
5253 *
5354 */
5455 const onMouseDownEnd = ( ) => {
55- setTimeout ( ( ) => setMouseDown ( false ) , 10 ) ;
56+ setTimeout ( ( ) => setMouseDown ( false ) , timeout ) ;
5657 } ;
5758
5859 /**
@@ -71,7 +72,7 @@ export const useMouseAction = (options: HooksInput): IProps => {
7172 */
7273 const onMouseUpTriggered = ( ) => {
7374 setMouseUpTriggered ( true ) ;
74- setTimeout ( ( ) => setMouseUpTriggered ( false ) , 10 ) ;
75+ setTimeout ( ( ) => setMouseUpTriggered ( false ) , timeout ) ;
7576 } ;
7677
7778 /**
@@ -199,7 +200,7 @@ export const useMouseAction = (options: HooksInput): IProps => {
199200 * prevent next coming click event to be catched
200201 * by a newly rendered element above the button.
201202 */
202- setTimeout ( ( ) => onAction ( event ) , 10 ) ;
203+ setTimeout ( ( ) => onAction ( event ) , timeout ) ;
203204 }
204205 } ;
205206
@@ -220,7 +221,7 @@ export const useMouseAction = (options: HooksInput): IProps => {
220221 * to be catched by a newly rendered element
221222 * above the button.
222223 */
223- setTimeout ( ( ) => onAction ( event ) , 10 ) ;
224+ setTimeout ( ( ) => onAction ( event ) , timeout ) ;
224225 }
225226 } ;
226227
0 commit comments