Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,21 @@ export function generateTrigger(
};
}

// ======================= Action: PointDown ========================
const pointDownToShow = showActions.has('pointerDown');
const pointDownToHide = hideActions.has('pointerDown');
if (pointDownToShow || pointDownToHide) {
cloneProps.onPointerDown = (event: React.PointerEvent<HTMLElement>, ...args: any[]) => {
if (openRef.current && pointDownToHide) {
triggerOpen(false); // to hide
} else if (!openRef.current && pointDownToShow) {
setMousePosByEvent(event);
triggerOpen(true);
}
// origin methods
originChildProps.onPointerDown?.(event, ...args);
}
}
// ======================= Action: Click ========================
if (clickToShow || clickToHide) {
cloneProps.onClick = (
Expand All @@ -541,7 +556,7 @@ export function generateTrigger(
};
}

// Click 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,
Expand All @@ -552,7 +567,6 @@ export function generateTrigger(
inPopupOrChild,
triggerOpen,
);

// ======================= Action: Hover ========================
const hoverToShow = showActions.has('hover');
const hoverToHide = hideActions.has('hover');
Expand Down Expand Up @@ -653,6 +667,7 @@ export function generateTrigger(
'onMouseLeave',
'onFocus',
'onBlur',
'onPointerDown',
];

passedEventList.forEach((eventName) => {
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export type BuildInPlacements = Record<string, AlignType>;

export type StretchType = string;

export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu' | 'pointerDown';

export type AnimationType = string;

Expand Down