How to properly align nodes with multiple parents

990 views Asked by At

Here's the screenshot

Space tree

I’ve been dealing with this problem and tried to modify the Y position without any luck. Notice that Meli Job B seems to be misaligned. This only happens if the parent box is attached to multiple parents. I tried the code below to know if a box have multiple parents but I can’t work on how I will position the Y-axis as they all fall in the same place.

Code:

var pos = node.getPos();
var parents = node.getParents();
if(parents.length > 1) {
    var subnodes = node.getSubnodes();
    for(var i=0; i<subnodes.length; i++) {
        var yPos = subnodes[i].getPos();
        yPos.y = pos.y;
    }
}

Thanks in advance for help.

1

There are 1 answers

0
Tarek On
var pos = node.getPos();
var parents = node.getParents();
var subnodes = node.getSubnodes();
for(var i=0; i<subnodes.length; i++) 
{
    var yPos = subnodes[i].getPos();
    if(parents.length > 1) 
        yPos.y = pos.y;
    else
        yPos.y = 0
}