fix: undo when erasing elements by clicking (#4921)
* fix: undo when erasing elements by clicking * newline remove
This commit is contained in:
parent
3aa0c5ebc0
commit
6d45430344
@ -2999,25 +2999,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isEraserActive(this.state)) {
|
if (isEraserActive(this.state)) {
|
||||||
const draggedDistance = distance2d(
|
|
||||||
this.lastPointerDown!.clientX,
|
|
||||||
this.lastPointerDown!.clientY,
|
|
||||||
this.lastPointerUp!.clientX,
|
|
||||||
this.lastPointerUp!.clientY,
|
|
||||||
);
|
|
||||||
if (draggedDistance === 0) {
|
|
||||||
const scenePointer = viewportCoordsToSceneCoords(
|
|
||||||
{ clientX: event.clientX, clientY: event.clientY },
|
|
||||||
this.state,
|
|
||||||
);
|
|
||||||
const hitElement = this.getElementAtPosition(
|
|
||||||
scenePointer.x,
|
|
||||||
scenePointer.y,
|
|
||||||
);
|
|
||||||
const pointerDownEvent = this.initialPointerDownState(event);
|
|
||||||
pointerDownEvent.hit.element = hitElement;
|
|
||||||
this.eraseElements(pointerDownEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.hitLinkElement &&
|
this.hitLinkElement &&
|
||||||
@ -4422,6 +4403,28 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
// drag or added to selection on pointer down phase.
|
// drag or added to selection on pointer down phase.
|
||||||
const hitElement = pointerDownState.hit.element;
|
const hitElement = pointerDownState.hit.element;
|
||||||
if (isEraserActive(this.state)) {
|
if (isEraserActive(this.state)) {
|
||||||
|
const draggedDistance = distance2d(
|
||||||
|
this.lastPointerDown!.clientX,
|
||||||
|
this.lastPointerDown!.clientY,
|
||||||
|
this.lastPointerUp!.clientX,
|
||||||
|
this.lastPointerUp!.clientY,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (draggedDistance === 0) {
|
||||||
|
const scenePointer = viewportCoordsToSceneCoords(
|
||||||
|
{
|
||||||
|
clientX: this.lastPointerUp!.clientX,
|
||||||
|
clientY: this.lastPointerUp!.clientY,
|
||||||
|
},
|
||||||
|
this.state,
|
||||||
|
);
|
||||||
|
const hitElement = this.getElementAtPosition(
|
||||||
|
scenePointer.x,
|
||||||
|
scenePointer.y,
|
||||||
|
);
|
||||||
|
|
||||||
|
pointerDownState.hit.element = hitElement;
|
||||||
|
}
|
||||||
this.eraseElements(pointerDownState);
|
this.eraseElements(pointerDownState);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user