fix: mobile context menu won't show on long press (#4741)
* scribble fix only if not Android * Update src/components/App.tsx Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
parent
66c92fc65a
commit
d450c36581
@ -163,6 +163,7 @@ import {
|
|||||||
shouldRotateWithDiscreteAngle,
|
shouldRotateWithDiscreteAngle,
|
||||||
isArrowKey,
|
isArrowKey,
|
||||||
KEYS,
|
KEYS,
|
||||||
|
isAndroid,
|
||||||
} from "../keys";
|
} from "../keys";
|
||||||
import { distance2d, getGridPoint, isPathALoop } from "../math";
|
import { distance2d, getGridPoint, isPathALoop } from "../math";
|
||||||
import { renderScene } from "../renderer";
|
import { renderScene } from "../renderer";
|
||||||
@ -1274,7 +1275,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
private onTapStart = (event: TouchEvent) => {
|
private onTapStart = (event: TouchEvent) => {
|
||||||
// fix for Apple Pencil Scribble
|
// fix for Apple Pencil Scribble
|
||||||
event.preventDefault();
|
// On Android, preventing the event would disable contextMenu on tap-hold
|
||||||
|
if (!isAndroid) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (!didTapTwice) {
|
if (!didTapTwice) {
|
||||||
didTapTwice = true;
|
didTapTwice = true;
|
||||||
@ -1297,6 +1301,9 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
didTapTwice = false;
|
didTapTwice = false;
|
||||||
clearTimeout(tappedTwiceTimer);
|
clearTimeout(tappedTwiceTimer);
|
||||||
}
|
}
|
||||||
|
if (isAndroid) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (event.touches.length === 2) {
|
if (event.touches.length === 2) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export const isDarwin = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
|
export const isDarwin = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
|
||||||
export const isWindows = /^Win/.test(window.navigator.platform);
|
export const isWindows = /^Win/.test(window.navigator.platform);
|
||||||
|
export const isAndroid = /\b(android)\b/i.test(navigator.userAgent);
|
||||||
|
|
||||||
export const CODES = {
|
export const CODES = {
|
||||||
EQUAL: "Equal",
|
EQUAL: "Equal",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user