Fix binding disabling when taking screenshots on macOS (#2129)
* Fix binding disabling when taking screenshots on macOS * Update snapshot for cmd+click test
This commit is contained in:
parent
924292dc9a
commit
15e4b51bb1
@ -171,6 +171,7 @@ import {
|
|||||||
isLinearElementSimpleAndAlreadyBound,
|
isLinearElementSimpleAndAlreadyBound,
|
||||||
isBindingEnabled,
|
isBindingEnabled,
|
||||||
updateBoundElements,
|
updateBoundElements,
|
||||||
|
shouldEnableBindingForPointerEvent,
|
||||||
} from "../element/binding";
|
} from "../element/binding";
|
||||||
import { MaybeTransformHandleType } from "../element/transformHandles";
|
import { MaybeTransformHandleType } from "../element/transformHandles";
|
||||||
|
|
||||||
@ -2220,6 +2221,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.clearSelectionIfNotUsingSelection();
|
this.clearSelectionIfNotUsingSelection();
|
||||||
|
this.updateBindingEnabledOnPointerMove(event);
|
||||||
|
|
||||||
if (this.handleSelectionOnPointerDown(event, pointerDownState)) {
|
if (this.handleSelectionOnPointerDown(event, pointerDownState)) {
|
||||||
return;
|
return;
|
||||||
@ -3484,6 +3486,15 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateBindingEnabledOnPointerMove = (
|
||||||
|
event: React.PointerEvent<HTMLCanvasElement>,
|
||||||
|
) => {
|
||||||
|
const shouldEnableBinding = shouldEnableBindingForPointerEvent(event);
|
||||||
|
if (this.state.isBindingEnabled !== shouldEnableBinding) {
|
||||||
|
this.setState({ isBindingEnabled: shouldEnableBinding });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private maybeSuggestBindingAtCursor = (pointerCoords: {
|
private maybeSuggestBindingAtCursor = (pointerCoords: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
@ -21,6 +21,7 @@ import { mutateElement } from "./mutateElement";
|
|||||||
import Scene from "../scene/Scene";
|
import Scene from "../scene/Scene";
|
||||||
import { LinearElementEditor } from "./linearElementEditor";
|
import { LinearElementEditor } from "./linearElementEditor";
|
||||||
import { tupleToCoors } from "../utils";
|
import { tupleToCoors } from "../utils";
|
||||||
|
import { KEYS } from "../keys";
|
||||||
|
|
||||||
export type SuggestedBinding =
|
export type SuggestedBinding =
|
||||||
| NonDeleted<ExcalidrawBindableElement>
|
| NonDeleted<ExcalidrawBindableElement>
|
||||||
@ -32,6 +33,12 @@ export type SuggestedPointBinding = [
|
|||||||
NonDeleted<ExcalidrawBindableElement>,
|
NonDeleted<ExcalidrawBindableElement>,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const shouldEnableBindingForPointerEvent = (
|
||||||
|
event: React.PointerEvent<HTMLCanvasElement>,
|
||||||
|
) => {
|
||||||
|
return !event[KEYS.CTRL_OR_CMD];
|
||||||
|
};
|
||||||
|
|
||||||
export const isBindingEnabled = (appState: AppState): boolean => {
|
export const isBindingEnabled = (appState: AppState): boolean => {
|
||||||
return appState.isBindingEnabled;
|
return appState.isBindingEnabled;
|
||||||
};
|
};
|
||||||
|
@ -907,7 +907,7 @@ Object {
|
|||||||
"exportBackground": true,
|
"exportBackground": true,
|
||||||
"gridSize": null,
|
"gridSize": null,
|
||||||
"height": 768,
|
"height": 768,
|
||||||
"isBindingEnabled": true,
|
"isBindingEnabled": false,
|
||||||
"isCollaborating": false,
|
"isCollaborating": false,
|
||||||
"isLibraryOpen": false,
|
"isLibraryOpen": false,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user