mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56:23 +01:00
Test only use longpress for iOS
This commit is contained in:
parent
d05f0a4f23
commit
a364488895
1 changed files with 22 additions and 12 deletions
|
@ -789,19 +789,29 @@ function Status({
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
});
|
});
|
||||||
|
const isIOS =
|
||||||
|
window.ontouchstart !== undefined &&
|
||||||
|
/iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||||
|
// Only iOS/iPadOS browsers don't support contextmenu
|
||||||
|
// Some comments report iPadOS might support contextmenu if a mouse is connected
|
||||||
const bindLongPressContext = useLongPress(
|
const bindLongPressContext = useLongPress(
|
||||||
(e) => {
|
isIOS
|
||||||
const { clientX, clientY } = e.touches?.[0] || e;
|
? (e) => {
|
||||||
// link detection copied from onContextMenu because here it works
|
if (e.pointerType === 'mouse') return;
|
||||||
const link = e.target.closest('a');
|
// There's 'pen' too, but not sure if contextmenu event would trigger from a pen
|
||||||
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;
|
|
||||||
e.preventDefault();
|
const { clientX, clientY } = e.touches?.[0] || e;
|
||||||
setContextMenuAnchorPoint({
|
// link detection copied from onContextMenu because here it works
|
||||||
x: clientX,
|
const link = e.target.closest('a');
|
||||||
y: clientY,
|
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;
|
||||||
});
|
e.preventDefault();
|
||||||
setIsContextMenuOpen(true);
|
setContextMenuAnchorPoint({
|
||||||
},
|
x: clientX,
|
||||||
|
y: clientY,
|
||||||
|
});
|
||||||
|
setIsContextMenuOpen(true);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
{
|
{
|
||||||
threshold: 600,
|
threshold: 600,
|
||||||
captureEvent: true,
|
captureEvent: true,
|
||||||
|
|
Loading…
Reference in a new issue