From 5ddfdd42a19076959698ffd5b541969a86910ca8 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 27 Sep 2023 15:21:30 -0700 Subject: [PATCH] cleanup --- d2layouts/d2layouts.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/d2layouts/d2layouts.go b/d2layouts/d2layouts.go index dddba2d44..866944389 100644 --- a/d2layouts/d2layouts.go +++ b/d2layouts/d2layouts.go @@ -122,8 +122,9 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co } curr = obj - dx := -curr.TopLeft.X - dy := -curr.TopLeft.Y + // position nested graph relative to curr + dx := 0 - curr.TopLeft.X + dy := 0 - curr.TopLeft.Y for _, o := range nestedGraph.Objects { o.TopLeft.X += dx o.TopLeft.Y += dy @@ -358,6 +359,9 @@ func PositionNested(container *d2graph.Object, nestedGraph *d2graph.Graph) { // Note: assumes nestedGraph's layout has contents positioned relative to 0,0 dx := container.TopLeft.X //- tl.X dy := container.TopLeft.Y //- tl.Y + if dx == 0 && dy == 0 { + return + } for _, o := range nestedGraph.Objects { o.TopLeft.X += dx o.TopLeft.Y += dy