Compare commits

...

4 Commits

Author SHA1 Message Date
dwelle
44660ce313 debug 2021-08-23 23:00:06 +02:00
dwelle
ac00b4ef2b prevent dragging the editing text element 2021-05-28 21:16:27 +02:00
dwelle
bf7810306c disable touble-tap-to-create-text on mobile 2021-05-28 21:15:43 +02:00
dwelle
9d0b7b0f2c stop disabling ts for handleCanvasDoubleClick 2021-05-28 21:14:52 +02:00

View File

@ -1204,11 +1204,16 @@ class App extends React.Component<AppProps, AppState> {
// event.touches.length === 1 will also prevent inserting text when user's zooming
if (didTapTwice && event.touches.length === 1) {
const [touch] = event.touches;
// @ts-ignore
this.handleCanvasDoubleClick({
clientX: touch.clientX,
clientY: touch.clientY,
});
this.handleCanvasDoubleClick(
{
clientX: touch.clientX,
clientY: touch.clientY,
ctrlKey: false,
metaKey: false,
altKey: false,
},
false,
);
didTapTwice = false;
clearTimeout(tappedTwiceTimer);
}
@ -1880,6 +1885,7 @@ class App extends React.Component<AppProps, AppState> {
sceneX,
sceneY,
insertAtParentCenter = true,
createTextIfNotExists = true,
}: {
/** X position to insert text at */
sceneX: number;
@ -1887,9 +1893,14 @@ class App extends React.Component<AppProps, AppState> {
sceneY: number;
/** whether to attempt to insert at element center if applicable */
insertAtParentCenter?: boolean;
createTextIfNotExists?: boolean;
}) => {
const existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);
// if (!existingTextElement && !createTextIfNotExists) {
// return;
// }
const parentCenterPosition =
insertAtParentCenter &&
this.getTextWysiwygSnappedToCenterPosition(
@ -1961,7 +1972,11 @@ class App extends React.Component<AppProps, AppState> {
};
private handleCanvasDoubleClick = (
event: React.MouseEvent<HTMLCanvasElement>,
event: Pick<
React.PointerEvent<HTMLCanvasElement>,
"clientX" | "clientY" | "ctrlKey" | "metaKey" | "altKey"
>,
createTextIfNotExists = true,
) => {
// case: double-clicking with arrow/line tool selected would both create
// text and enter multiElement mode
@ -2032,6 +2047,7 @@ class App extends React.Component<AppProps, AppState> {
sceneX,
sceneY,
insertAtParentCenter: !event.altKey,
createTextIfNotExists,
});
}
};
@ -3190,7 +3206,7 @@ class App extends React.Component<AppProps, AppState> {
const selectedElements = getSelectedElements(
this.scene.getElements(),
this.state,
);
).filter((element) => element.id !== this.state.editingElement?.id);
// prevent dragging even if we're no longer holding cmd/ctrl otherwise
// it would have weird results (stuff jumping all over the screen)
if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl) {