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
@@ -90,14 +90,14 @@ function ResizeControl({
changes.push(dimensionChange); changes.push(dimensionChange);
} }
childChanges.forEach((childChange) => { for (const childChange of childChanges) {
const positionChange: NodePositionChange = { const positionChange: NodePositionChange = {
...childChange, ...childChange,
type: 'position', type: 'position',
}; };
changes.push(positionChange); changes.push(positionChange);
}); }
triggerNodeChanges(changes); triggerNodeChanges(changes);
}, },
@@ -77,12 +77,12 @@
? { x: change.x, y: change.y } ? { x: change.x, y: change.y }
: node.position; : node.position;
childChanges.forEach((childChange) => { for (const childChange of childChanges) {
const childNode = $nodeLookup.get(childChange.id); const childNode = $nodeLookup.get(childChange.id);
if (childNode) { if (childNode) {
childNode.position = childChange.position; childNode.position = childChange.position;
} }
}); }
$nodes = $nodes; $nodes = $nodes;
} }
+4 -4
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 // Determine largest minimal extent the parent node is allowed to resize to
childNodes = []; childNodes = [];
childExtent = undefined; childExtent = undefined;
nodeLookup.forEach((child, childId) => { for (const [childId, child] of nodeLookup) {
if (child.parentNode === nodeId) { if (child.parentNode === nodeId) {
childNodes.push({ childNodes.push({
id: childId, id: childId,
@@ -163,7 +163,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
} }
} }
} }
}); }
onResizeStart?.(event, { ...prevValues }); onResizeStart?.(event, { ...prevValues });
} }
@@ -222,13 +222,13 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
if (childNodes.length > 0) { if (childNodes.length > 0) {
const xChange = x - prevX; const xChange = x - prevX;
const yChange = y - prevY; const yChange = y - prevY;
childNodes.forEach((childNode) => { for (const childNode of childNodes) {
childNode.position = { childNode.position = {
x: childNode.position.x - xChange, x: childNode.position.x - xChange,
y: childNode.position.y - yChange, y: childNode.position.y - yChange,
}; };
childChanges.push(childNode); childChanges.push(childNode);
}); }
} }
} }