This commit is contained in:
Gavin Nishizawa 2023-09-27 15:21:30 -07:00
parent 15a22000a7
commit 5ddfdd42a1
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -122,8 +122,9 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co
} }
curr = obj curr = obj
dx := -curr.TopLeft.X // position nested graph relative to curr
dy := -curr.TopLeft.Y dx := 0 - curr.TopLeft.X
dy := 0 - curr.TopLeft.Y
for _, o := range nestedGraph.Objects { for _, o := range nestedGraph.Objects {
o.TopLeft.X += dx o.TopLeft.X += dx
o.TopLeft.Y += dy 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 // Note: assumes nestedGraph's layout has contents positioned relative to 0,0
dx := container.TopLeft.X //- tl.X dx := container.TopLeft.X //- tl.X
dy := container.TopLeft.Y //- tl.Y dy := container.TopLeft.Y //- tl.Y
if dx == 0 && dy == 0 {
return
}
for _, o := range nestedGraph.Objects { for _, o := range nestedGraph.Objects {
o.TopLeft.X += dx o.TopLeft.X += dx
o.TopLeft.Y += dy o.TopLeft.Y += dy