Comparing version 3.1.10 to 3.1.11
@@ -6,4 +6,5 @@ import type { BasicTarget } from '../utils/domTarget'; | ||
onClick?: (event: EventType) => void; | ||
onLongPressEnd?: (event: EventType) => void; | ||
} | ||
declare function useLongPress(onLongPress: (event: EventType) => void, target: BasicTarget, { delay, onClick }?: Options): void; | ||
declare function useLongPress(onLongPress: (event: EventType) => void, target: BasicTarget, { delay, onClick, onLongPressEnd }?: Options): void; | ||
export default useLongPress; |
@@ -13,6 +13,8 @@ import { useRef } from 'react'; | ||
delay = _c === void 0 ? 300 : _c, | ||
onClick = _b.onClick; | ||
onClick = _b.onClick, | ||
onLongPressEnd = _b.onLongPressEnd; | ||
var onLongPressRef = useLatest(onLongPress); | ||
var onClickRef = useLatest(onClick); | ||
var onLongPressEndRef = useLatest(onLongPressEnd); | ||
var timerRef = useRef(); | ||
@@ -35,2 +37,4 @@ var isTriggeredRef = useRef(false); | ||
var onEnd = function onEnd(event, shouldTriggerClick) { | ||
var _a; | ||
if (shouldTriggerClick === void 0) { | ||
@@ -44,2 +48,6 @@ shouldTriggerClick = false; | ||
if (isTriggeredRef.current) { | ||
(_a = onLongPressEndRef.current) === null || _a === void 0 ? void 0 : _a.call(onLongPressEndRef, event); | ||
} | ||
if (shouldTriggerClick && !isTriggeredRef.current && onClickRef.current) { | ||
@@ -46,0 +54,0 @@ onClickRef.current(event); |
@@ -6,4 +6,5 @@ import type { BasicTarget } from '../utils/domTarget'; | ||
onClick?: (event: EventType) => void; | ||
onLongPressEnd?: (event: EventType) => void; | ||
} | ||
declare function useLongPress(onLongPress: (event: EventType) => void, target: BasicTarget, { delay, onClick }?: Options): void; | ||
declare function useLongPress(onLongPress: (event: EventType) => void, target: BasicTarget, { delay, onClick, onLongPressEnd }?: Options): void; | ||
export default useLongPress; |
@@ -30,6 +30,8 @@ "use strict"; | ||
delay = _c === void 0 ? 300 : _c, | ||
onClick = _b.onClick; | ||
onClick = _b.onClick, | ||
onLongPressEnd = _b.onLongPressEnd; | ||
var onLongPressRef = useLatest_1["default"](onLongPress); | ||
var onClickRef = useLatest_1["default"](onClick); | ||
var onLongPressEndRef = useLatest_1["default"](onLongPressEnd); | ||
var timerRef = react_1.useRef(); | ||
@@ -52,2 +54,4 @@ var isTriggeredRef = react_1.useRef(false); | ||
var onEnd = function onEnd(event, shouldTriggerClick) { | ||
var _a; | ||
if (shouldTriggerClick === void 0) { | ||
@@ -61,2 +65,6 @@ shouldTriggerClick = false; | ||
if (isTriggeredRef.current) { | ||
(_a = onLongPressEndRef.current) === null || _a === void 0 ? void 0 : _a.call(onLongPressEndRef, event); | ||
} | ||
if (shouldTriggerClick && !isTriggeredRef.current && onClickRef.current) { | ||
@@ -63,0 +71,0 @@ onClickRef.current(event); |
{ | ||
"name": "ahooks", | ||
"version": "3.1.10", | ||
"version": "3.1.11", | ||
"description": "react hooks library", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"gitHead": "66b2b254ff885f44c46f13fe318e488ae64eab5d" | ||
"gitHead": "f18b1f38f6f2f4180a244354fb73a13494b1cf4b" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
632115
15708