Can't align nodes horizontally

Hi

I’ve created this Codesandbox sample to better demonstrate my issue:

I have four nodes:

  • Unit One does not have `topArray`, Unit Two have it;
  • Unit Three does not have `topArray`, Unit Four have it;

If I try to align them vertically using `Part.moveTo` it does not look right. I just want to align the rectangle of both Nodes so that they perfectly overlap without having to care about port arrays.

Does GoJS have an API to achieve this without assuming anything about port arrays?

Use Part.location instead of Part.position. Instead of:

node2.moveTo(node1.position.x, node1.position.y);
node3.moveTo(node4.position.x, node4.position.y);

Try:

node2.move(node1.location, true);
node3.move(node4.location, true);
1 Like