feat(nodes): Add PositionFunc as node position type
* Allows position to be set relative to another node
This commit is contained in:
@@ -99,10 +99,16 @@ const createGraphNodes = (nodes: Node[], getNode: Getters['getNode'], currGraphN
|
||||
})
|
||||
|
||||
graphNodes.forEach((node) => {
|
||||
if (node.parentNode && ![...graphNodes, ...currGraphNodes].find((n) => n.id === node.parentNode)) {
|
||||
const nextNodes = [...graphNodes, ...currGraphNodes]
|
||||
if (node.parentNode && !nextNodes.find((n) => n.id === node.parentNode)) {
|
||||
console.warn(`[vueflow]: Parent node ${node.parentNode} not found`)
|
||||
}
|
||||
const position =
|
||||
(<any>node).position instanceof Function
|
||||
? (<any>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
|
||||
|
||||
Reference in New Issue
Block a user