Skip to content

Commit

Permalink
Implement handling of possible touch event
Browse files Browse the repository at this point in the history
  • Loading branch information
JunoNgx committed Mar 30, 2024
1 parent c7a5d09 commit 7f397c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions package/ContextMenuProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ export function ContextMenuProvider({
setData(null);
};

const showContextMenu: ShowContextMenuFunction = (content, options) => (e) => {
const showContextMenu: ShowContextMenuFunction = (content, options) => (e: React.MouseEvent | React.TouchEvent) => {
e.preventDefault();
e.stopPropagation();

const x = "touches" in e
? e.touches[0].clientX
: e.clientX;
const y = "touches" in e
? e.touches[0].clientY
: e.clientY;

setData({
x: e.clientX,
y: e.clientY,
x,
y,
content,
zIndex: options?.zIndex || zIndex,
className: options?.className,
Expand Down

0 comments on commit 7f397c7

Please sign in to comment.