From c964fb6b7d82d26e94eba42469cc0ae4c4d29ba0 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 7 Apr 2022 12:07:14 +0200 Subject: [PATCH] refactor(nodes): Remove position func * it's not improving on existing methods, i.e. no real benefit to it --- package/src/store/actions.ts | 5 ----- package/src/types/node.ts | 9 +-------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/package/src/store/actions.ts b/package/src/store/actions.ts index 62c9d5b1..e9541359 100644 --- a/package/src/store/actions.ts +++ b/package/src/store/actions.ts @@ -103,12 +103,7 @@ const createGraphNodes = (nodes: Node[], getNode: Getters['getNode'], currGraphN if (node.parentNode && !nextNodes.find((n) => n.id === node.parentNode)) { console.warn(`[vueflow]: Parent node ${node.parentNode} not found`) } - const position = - (node).position instanceof Function - ? (node).position(node, currGraphNodes, node.parentNode ? getNode(node.parentNode) : undefined) - : node.position - if (position) node.position = position if (node.parentNode || parentNodes[node.id]) { if (parentNodes[node.id]) { node.isParent = true diff --git a/package/src/types/node.ts b/package/src/types/node.ts index ce83ad22..370487cb 100644 --- a/package/src/types/node.ts +++ b/package/src/types/node.ts @@ -10,17 +10,12 @@ export type NodeHandleBounds = { target?: HandleElement[] } -type PositionFunc = ( - node: GraphNode, - currNodes: GraphNode[], - parentNode: GraphNode, -) => XYPosition type WidthFunc = (node: GraphNode) => number | string | void type HeightFunc = (node: GraphNode) => number | string | void export interface Node extends Element { /** initial node position x, y */ - position: XYPosition | PositionFunc + position: XYPosition /** node type, can be a default type or a custom type */ type?: keyof DefaultNodeTypes | string /** handle position */ @@ -60,8 +55,6 @@ export interface Node extends Element { } export interface GraphNode extends Node { - /** current node position x, y */ - position: XYPosition /** absolute position in relation to parent elements + z-index */ computedPosition: XYZPosition handleBounds: NodeHandleBounds