double click to start cropping
This commit is contained in:
parent
51ea184938
commit
3d92a3bf1f
@ -116,6 +116,8 @@ export const getDefaultAppState = (): Omit<
|
||||
objectsSnapModeEnabled: false,
|
||||
userToFollow: null,
|
||||
followedBy: new Set(),
|
||||
isCropping: false,
|
||||
croppingElement: null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -236,6 +238,8 @@ const APP_STATE_STORAGE_CONF = (<
|
||||
objectsSnapModeEnabled: { browser: true, export: false, server: false },
|
||||
userToFollow: { browser: false, export: false, server: false },
|
||||
followedBy: { browser: false, export: false, server: false },
|
||||
isCropping: { browser: false, export: false, server: false },
|
||||
croppingElement: { browser: false, export: false, server: false },
|
||||
});
|
||||
|
||||
const _clearAppStateForStorage = <
|
||||
|
@ -5073,6 +5073,20 @@ class App extends React.Component<AppProps, AppState> {
|
||||
}
|
||||
};
|
||||
|
||||
private startImageCropping = (image: ExcalidrawImageElement) => {
|
||||
this.setState({
|
||||
croppingElement: image,
|
||||
isCropping: true,
|
||||
});
|
||||
};
|
||||
|
||||
private finishImageCropping = () => {
|
||||
this.setState({
|
||||
isCropping: false,
|
||||
croppingElement: null,
|
||||
});
|
||||
};
|
||||
|
||||
private handleCanvasDoubleClick = (
|
||||
event: React.MouseEvent<HTMLCanvasElement>,
|
||||
) => {
|
||||
@ -5104,6 +5118,11 @@ class App extends React.Component<AppProps, AppState> {
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedElements.length === 1 && isImageElement(selectedElements[0])) {
|
||||
this.startImageCropping(selectedElements[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
resetCursor(this.interactiveCanvas);
|
||||
|
||||
let { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords(
|
||||
|
@ -384,6 +384,10 @@ export interface AppState {
|
||||
userToFollow: UserToFollow | null;
|
||||
/** the socket ids of the users following the current user */
|
||||
followedBy: Set<SocketId>;
|
||||
|
||||
/** image cropping */
|
||||
isCropping: boolean;
|
||||
croppingElement: ExcalidrawImageElement | null;
|
||||
}
|
||||
|
||||
export type UIAppState = Omit<
|
||||
|
Loading…
x
Reference in New Issue
Block a user