refactor(element-updates): check if node type changed
This commit is contained in:
+5
-3
@@ -219,6 +219,7 @@ export const storeModel: StoreModel = {
|
|||||||
const propNode = el as Node;
|
const propNode = el as Node;
|
||||||
const positionChanged =
|
const positionChanged =
|
||||||
storeElement.position.x !== propNode.position.x || storeElement.position.y !== propNode.position.y;
|
storeElement.position.x !== propNode.position.x || storeElement.position.y !== propNode.position.y;
|
||||||
|
const typeChanged = typeof propNode.type !== 'undefined' && propNode.type !== storeElement.type;
|
||||||
|
|
||||||
state.elements[storeElementIndex] = {
|
state.elements[storeElementIndex] = {
|
||||||
...storeElement,
|
...storeElement,
|
||||||
@@ -228,9 +229,10 @@ export const storeModel: StoreModel = {
|
|||||||
if (positionChanged) {
|
if (positionChanged) {
|
||||||
(state.elements[storeElementIndex] as Node).__rf.position = propNode.position;
|
(state.elements[storeElementIndex] as Node).__rf.position = propNode.position;
|
||||||
}
|
}
|
||||||
// we reset the elements dimensions here in order to force a re-calculation of the bounds.
|
|
||||||
// When the type of a node changes it is possible that the number or positions of handles changes too.
|
if (typeChanged) {
|
||||||
if (typeof propNode.type !== 'undefined' && propNode.type !== storeElement.type) {
|
// we reset the elements dimensions here in order to force a re-calculation of the bounds.
|
||||||
|
// When the type of a node changes it is possible that the number or positions of handles changes too.
|
||||||
(state.elements[storeElementIndex] as Node).__rf.width = null;
|
(state.elements[storeElementIndex] as Node).__rf.width = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user