Visualize Your Ideas With Code
fix(2d): fix layout calculation for nodes not explicitly added to view (#331)
Kai Sassnowski528e2d5a0abe
diff --git a/packages/2d/src/components/Node.ts b/packages/2d/src/components/Node.tsindex 4881a439..fa450108 100644--- a/packages/2d/src/components/Node.ts+++ b/packages/2d/src/components/Node.ts@@ -375,6 +375,7 @@ export class Node implements Promisable<Node> {}}+ private view2D: View2D;private realChildren: Node[] = [];public readonly parent = createSignal<Node | null>(null);public readonly properties = getPropertiesOf(this);@@ -382,7 +383,9 @@ export class Node implements Promisable<Node> {public readonly creationStack?: string;public constructor({children, spawner, key, ...rest}: NodeProps) {- this.key = useScene2D()?.registerNode(this, key) ?? key ?? '';+ const scene = useScene2D();+ this.key = scene.registerNode(this, key);+ this.view2D = scene.getView();this.creationStack = new Error().stack;initialize(this, {defaults: rest});for (const {signal} of this) {@@ -525,9 +528,8 @@ export class Node implements Promisable<Node> {return new DOMMatrix();}- @computed()public view(): View2D | null {- return this.parent()?.view() ?? null;+ return this.view2D;}/**