use for..of instead of forEach

This commit is contained in:
peterkogo
2024-01-30 13:25:02 +01:00
parent 5746c7b6fb
commit c9b1b78edf
3 changed files with 8 additions and 8 deletions

View File

@@ -90,14 +90,14 @@ function ResizeControl({
changes.push(dimensionChange);
}
childChanges.forEach((childChange) => {
for (const childChange of childChanges) {
const positionChange: NodePositionChange = {
...childChange,
type: 'position',
};
changes.push(positionChange);
});
}
triggerNodeChanges(changes);
},

View File

@@ -77,12 +77,12 @@
? { x: change.x, y: change.y }
: node.position;
childChanges.forEach((childChange) => {
for (const childChange of childChanges) {
const childNode = $nodeLookup.get(childChange.id);
if (childNode) {
childNode.position = childChange.position;
}
});
}
$nodes = $nodes;
}

View File

@@ -144,7 +144,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
// Determine largest minimal extent the parent node is allowed to resize to
childNodes = [];
childExtent = undefined;
nodeLookup.forEach((child, childId) => {
for (const [childId, child] of nodeLookup) {
if (child.parentNode === nodeId) {
childNodes.push({
id: childId,
@@ -163,7 +163,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
}
}
}
});
}
onResizeStart?.(event, { ...prevValues });
}
@@ -222,13 +222,13 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
if (childNodes.length > 0) {
const xChange = x - prevX;
const yChange = y - prevY;
childNodes.forEach((childNode) => {
for (const childNode of childNodes) {
childNode.position = {
x: childNode.position.x - xChange,
y: childNode.position.y - yChange,
};
childChanges.push(childNode);
});
}
}
}