fix: cancel erase elements on pointer up if eraser is not active on pointer up (#4956)
* fix: erase elements on pointer up if present * cancel erase on pointer up if eraser is not active
This commit is contained in:
parent
cded1cd63d
commit
db28595302
@ -4472,6 +4472,8 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
}
|
}
|
||||||
this.eraseElements(pointerDownState);
|
this.eraseElements(pointerDownState);
|
||||||
return;
|
return;
|
||||||
|
} else if (Object.keys(pointerDownState.elementIdsToErase).length) {
|
||||||
|
this.restoreReadyToEraseElements(pointerDownState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -4613,6 +4615,32 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private restoreReadyToEraseElements = (
|
||||||
|
pointerDownState: PointerDownState,
|
||||||
|
) => {
|
||||||
|
const elements = this.scene.getElements().map((ele) => {
|
||||||
|
if (
|
||||||
|
pointerDownState.elementIdsToErase[ele.id] &&
|
||||||
|
pointerDownState.elementIdsToErase[ele.id].erase
|
||||||
|
) {
|
||||||
|
return newElementWith(ele, {
|
||||||
|
opacity: pointerDownState.elementIdsToErase[ele.id].opacity,
|
||||||
|
});
|
||||||
|
} else if (
|
||||||
|
isBoundToContainer(ele) &&
|
||||||
|
pointerDownState.elementIdsToErase[ele.containerId] &&
|
||||||
|
pointerDownState.elementIdsToErase[ele.containerId].erase
|
||||||
|
) {
|
||||||
|
return newElementWith(ele, {
|
||||||
|
opacity: pointerDownState.elementIdsToErase[ele.containerId].opacity,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ele;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.scene.replaceAllElements(elements);
|
||||||
|
};
|
||||||
|
|
||||||
private eraseElements = (pointerDownState: PointerDownState) => {
|
private eraseElements = (pointerDownState: PointerDownState) => {
|
||||||
const elements = this.scene.getElements().map((ele) => {
|
const elements = this.scene.getElements().map((ele) => {
|
||||||
if (
|
if (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user