From 1be7cd67081fb6fd6822c8fc5e3a62e5d937a6d5 Mon Sep 17 00:00:00 2001 From: enson_chen <1004714132@qq.com> Date: Thu, 22 Feb 2024 11:49:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20pointerDown=20act?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.tsx | 19 +++++++++++++++++-- src/interface.ts | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index d55c6b1d..a9b45451 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -523,6 +523,21 @@ export function generateTrigger( }; } + // ======================= Action: PointDown ======================== + const pointDownToShow = showActions.has('pointDown'); + const pointDownToHide = hideActions.has('pointDown'); + if (pointDownToShow || pointDownToHide) { + cloneProps.onPointDown = (event: React.PointerEvent, ...args: any[]) => { + if (openRef.current && pointDownToHide) { + triggerOpen(false); // to hide + } else if (!openRef.current && pointDownToShow) { + setMousePosByEvent(event); + triggerOpen(true); + } + // origin methods + originChildProps.onPointDown?.(event, ...args); + } + } // ======================= Action: Click ======================== if (clickToShow || clickToHide) { cloneProps.onClick = ( @@ -541,7 +556,7 @@ export function generateTrigger( }; } - // Click to hide is special action since click popup element should not hide + // Click/PointDown to hide is special action since click popup element should not hide useWinClick( mergedOpen, clickToHide, @@ -552,7 +567,7 @@ export function generateTrigger( inPopupOrChild, triggerOpen, ); - + // ======================= Action: Hover ======================== const hoverToShow = showActions.has('hover'); const hoverToHide = hideActions.has('hover'); diff --git a/src/interface.ts b/src/interface.ts index ddb27eec..898c1507 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -104,7 +104,7 @@ export type BuildInPlacements = Record; export type StretchType = string; -export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu'; +export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu' | 'pointDown'; export type AnimationType = string; From 526263e81a6f57c2431d1836fe2aec73e818587e Mon Sep 17 00:00:00 2001 From: enson_chen <1004714132@qq.com> Date: Thu, 22 Feb 2024 11:55:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=F0=9F=90=9E=20add=20pointerDown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.tsx b/src/index.tsx index a9b45451..464a6e72 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -668,6 +668,7 @@ export function generateTrigger( 'onMouseLeave', 'onFocus', 'onBlur', + 'onPointerDown', ]; passedEventList.forEach((eventName) => { From b894b0dc774459b261ce38603281927994f40119 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 3 Sep 2024 15:11:17 +0800 Subject: [PATCH 3/4] Update src/index.tsx --- src/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 464a6e72..72172255 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -567,7 +567,6 @@ export function generateTrigger( inPopupOrChild, triggerOpen, ); - // ======================= Action: Hover ======================== const hoverToShow = showActions.has('hover'); const hoverToHide = hideActions.has('hover'); From a3ada2f3b25e310c6e2d7f6a80b940558a43f793 Mon Sep 17 00:00:00 2001 From: enson_chen <1004714132@qq.com> Date: Tue, 3 Sep 2024 16:08:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=F0=9F=90=9E=20fix=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.tsx | 10 +++++----- src/interface.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 464a6e72..75362d15 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -524,10 +524,10 @@ export function generateTrigger( } // ======================= Action: PointDown ======================== - const pointDownToShow = showActions.has('pointDown'); - const pointDownToHide = hideActions.has('pointDown'); + const pointDownToShow = showActions.has('pointerDown'); + const pointDownToHide = hideActions.has('pointerDown'); if (pointDownToShow || pointDownToHide) { - cloneProps.onPointDown = (event: React.PointerEvent, ...args: any[]) => { + cloneProps.onPointerDown = (event: React.PointerEvent, ...args: any[]) => { if (openRef.current && pointDownToHide) { triggerOpen(false); // to hide } else if (!openRef.current && pointDownToShow) { @@ -535,7 +535,7 @@ export function generateTrigger( triggerOpen(true); } // origin methods - originChildProps.onPointDown?.(event, ...args); + originChildProps.onPointerDown?.(event, ...args); } } // ======================= Action: Click ======================== @@ -556,7 +556,7 @@ export function generateTrigger( }; } - // Click/PointDown to hide is special action since click popup element should not hide + // Click/PointerDown to hide is special action since click popup element should not hide useWinClick( mergedOpen, clickToHide, diff --git a/src/interface.ts b/src/interface.ts index 898c1507..8775800b 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -104,7 +104,7 @@ export type BuildInPlacements = Record; export type StretchType = string; -export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu' | 'pointDown'; +export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu' | 'pointerDown'; export type AnimationType = string;