Skip to content

Commit c0ae9cf

Browse files
committed
🐛 修复选中实体跳入文本节点,文本节点自动转换为框后,跳入的实体全都重叠在一点的情况
1 parent a962a75 commit c0ae9cf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
app/src-tauri
22

33
# 防止翻译总是被格式化
4-
app/locales/*.yml
4+
*.yml

app/src/core/service/controlService/controller/concrete/ControllerEntityLayerMoving.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ ControllerLayerMoving.mouseup = (event: MouseEvent) => {
4141
if (entity && entity instanceof TextNode) {
4242
const newSection = StageSectionPackManager.targetTextNodeToSection(entity);
4343
const selectedEntities = StageManager.getSelectedEntities();
44-
// StageManager.goInSection(StageManager.getSelectedEntities(), newSection);
45-
StageSectionInOutManager.goInSections(StageManager.getSelectedEntities(), [newSection]);
44+
// 获取所有选中实体的外接矩形的中心点,以便计算移动距离
45+
const centerLocation = Rectangle.getBoundingRectangle(
46+
selectedEntities.map((entity) => entity.collisionBox.getRectangle()),
47+
).center;
4648
// 最后让所有选中的实体移动
4749
for (const selectedEntity of selectedEntities) {
48-
selectedEntity.moveTo(mouseLocation);
50+
const delta = mouseLocation.subtract(centerLocation);
51+
selectedEntity.move(delta);
4952
}
53+
StageSectionInOutManager.goInSections(StageManager.getSelectedEntities(), [newSection]);
5054
return; // 这个return必须写
5155
}
5256

0 commit comments

Comments
 (0)