Skip to content

Commit 33dc8b9

Browse files
fix: rotated groups persisted wrong coordinates to simulation
1 parent 04ab486 commit 33dc8b9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

srcjs/src/lib/Editor.svelte

+8-4
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,16 @@
140140
graph.forEachNode((node) => {
141141
const rect = rectsByNodeId.get(node.id);
142142
if ("component" in node.data) {
143-
// TODO: Actually we have to use the group's transform matrix
144-
// manually offseting by the group's position will not suffice
143+
// TODO: This should be made recursive like updateLines
144+
const pointRelativeToParent = new Point(rect.left, rect.top);
145+
const pointRelativeToGrandparent = pointRelativeToParent.transform(
146+
rect.group.calcTransformMatrix()
147+
);
148+
145149
layout.setNodePosition(
146150
node.id,
147-
rect.left + rect.group.left - offset,
148-
rect.top + rect.group.top - offset,
151+
pointRelativeToGrandparent.x - offset,
152+
pointRelativeToGrandparent.y - offset,
149153
)
150154
} else {
151155
layout.setNodePosition(node.id, rect.left - offset, rect.top - offset);

0 commit comments

Comments
 (0)