feat(store): flatten child map of nodes

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent e2d60bedfd
commit 0450ba2eae
5 changed files with 46 additions and 28 deletions
+3 -4
View File
@@ -163,7 +163,8 @@ export const pointToRendererPoint = (
export const onLoadProject = (currentStore: FlowStore) => (position: XYPosition) =>
pointToRendererPoint(position, currentStore.transform, currentStore.snapToGrid, currentStore.snapGrid)
export const parseNode = (node: Node, nodeExtent: CoordinateExtent): GraphNode => ({
export const parseNode = (node: Node, nodeExtent: CoordinateExtent, defaults?: Partial<GraphNode>): GraphNode => ({
...defaults,
...node,
id: node.id.toString(),
type: node.type ?? 'default',
@@ -322,9 +323,7 @@ export function calculateXYZPosition(node: GraphNode, result: XYZPosition): XYZP
x: result.x + node.parentNode.position.x,
y: result.y + node.parentNode.position.y,
z:
node.parentNode.computedPosition.z > node.computedPosition.z
? node.parentNode.computedPosition.z + 1
: node.computedPosition.z,
node.parentNode.computedPosition.z > node.computedPosition.z ? node.parentNode.computedPosition.z : node.computedPosition.z,
})
}