Remove resized element if it is invisibly small (#405)
This commit is contained in:
parent
4234cd849c
commit
8bc049a0b9
@ -12,3 +12,4 @@ export { resizeTest } from "./resizeTest";
|
|||||||
export { isTextElement } from "./typeChecks";
|
export { isTextElement } from "./typeChecks";
|
||||||
export { textWysiwyg } from "./textWysiwyg";
|
export { textWysiwyg } from "./textWysiwyg";
|
||||||
export { redrawTextBoundingBox } from "./textElement";
|
export { redrawTextBoundingBox } from "./textElement";
|
||||||
|
export { isInvisiblySmallElement } from "./sizeChecks";
|
||||||
|
5
src/element/sizeChecks.ts
Normal file
5
src/element/sizeChecks.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { ExcalidrawElement } from "./types";
|
||||||
|
|
||||||
|
export function isInvisiblySmallElement(element: ExcalidrawElement): boolean {
|
||||||
|
return element.width === 0 && element.height === 0;
|
||||||
|
}
|
@ -8,6 +8,7 @@ import {
|
|||||||
newElement,
|
newElement,
|
||||||
duplicateElement,
|
duplicateElement,
|
||||||
resizeTest,
|
resizeTest,
|
||||||
|
isInvisiblySmallElement,
|
||||||
isTextElement,
|
isTextElement,
|
||||||
textWysiwyg,
|
textWysiwyg,
|
||||||
getElementAbsoluteCoords
|
getElementAbsoluteCoords
|
||||||
@ -978,7 +979,11 @@ export class App extends React.Component<{}, AppState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onMouseUp = (e: MouseEvent) => {
|
const onMouseUp = (e: MouseEvent) => {
|
||||||
const { draggingElement, elementType } = this.state;
|
const {
|
||||||
|
draggingElement,
|
||||||
|
resizingElement,
|
||||||
|
elementType
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
lastMouseUp = null;
|
lastMouseUp = null;
|
||||||
window.removeEventListener("mousemove", onMouseMove);
|
window.removeEventListener("mousemove", onMouseMove);
|
||||||
@ -987,8 +992,7 @@ export class App extends React.Component<{}, AppState> {
|
|||||||
if (
|
if (
|
||||||
elementType !== "selection" &&
|
elementType !== "selection" &&
|
||||||
draggingElement &&
|
draggingElement &&
|
||||||
draggingElement.width === 0 &&
|
isInvisiblySmallElement(draggingElement)
|
||||||
draggingElement.height === 0
|
|
||||||
) {
|
) {
|
||||||
// remove invisible element which was added in onMouseDown
|
// remove invisible element which was added in onMouseDown
|
||||||
elements = elements.slice(0, -1);
|
elements = elements.slice(0, -1);
|
||||||
@ -999,6 +1003,10 @@ export class App extends React.Component<{}, AppState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resizingElement && isInvisiblySmallElement(resizingElement)) {
|
||||||
|
elements = elements.filter(el => el.id !== resizingElement.id);
|
||||||
|
}
|
||||||
|
|
||||||
resetCursor();
|
resetCursor();
|
||||||
|
|
||||||
// If click occured on already selected element
|
// If click occured on already selected element
|
||||||
|
Loading…
x
Reference in New Issue
Block a user