Skip to content

Commit 28845cc

Browse files
committed
🐛 fix: #310 节点转化为框明显一点,但转换后还有向上移动一段距离的bug
1 parent 176f479 commit 28845cc

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

app/src/core/stage/stageManager/concreteMethods/StageSectionPackManager.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export namespace StageSectionPackManager {
7272
}
7373
// 获取这个节点的父级Section
7474
const fatherSections = SectionMethods.getFatherSections(textNode);
75-
const rect = textNode.collisionBox.getRectangle();
75+
const rect = textNode.collisionBox.getRectangle().expandFromCenter(50);
7676
const newSection = new Section({
7777
uuid: v4(),
7878
text: textNode.text,
@@ -81,6 +81,7 @@ export namespace StageSectionPackManager {
8181
color: [textNode.color.r, textNode.color.g, textNode.color.b, textNode.color.a],
8282
details: textNode.details,
8383
});
84+
newSection.adjustLocationAndSize();
8485
// 获取所有连向它的和它连向的东西
8586
const fatherConnections = GraphMethods.nodeParentArray(textNode);
8687
const childConnections = GraphMethods.nodeChildrenArray(textNode);

app/src/core/stage/stageObject/entity/Section.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,17 @@ export class Section extends ConnectableEntity {
128128
}
129129

130130
adjustLocationAndSize() {
131+
let rectangle: Rectangle;
131132
if (this.children.length === 0) {
132-
return;
133+
rectangle = new Rectangle(this.collisionBox.getRectangle().location, new Vector(100, 100));
134+
} else {
135+
// 调整展开状态
136+
rectangle = Rectangle.getBoundingRectangle(
137+
this.children.map((child) => child.collisionBox.getRectangle()),
138+
30,
139+
);
133140
}
134-
// 调整展开状态
135-
const rectangle = Rectangle.getBoundingRectangle(
136-
this.children.map((child) => child.collisionBox.getRectangle()),
137-
30,
138-
);
141+
139142
// 留白范围在上面调整
140143
rectangle.location = rectangle.location.subtract(new Vector(0, 50));
141144
rectangle.size = rectangle.size.add(new Vector(0, 50));

0 commit comments

Comments
 (0)