Skip to content

Commit 797ed39

Browse files
committed
🚸 alt+方向键在实体周围创建节点时,空隙距离更加紧凑
1 parent f87491e commit 797ed39

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ export namespace StageNodeAdder {
114114
const distance = newNode.rectangle.left - entityRectangle.left;
115115
newNode.moveTo(newNode.rectangle.location.add(new Vector(-distance, 0)));
116116
}
117+
if (direction === Direction.Left) {
118+
// 顶对齐
119+
const distance = newNode.rectangle.top - entityRectangle.top;
120+
newNode.moveTo(newNode.rectangle.location.add(new Vector(0, -distance)));
121+
}
122+
if (direction === Direction.Right) {
123+
// 顶对齐,+ 自己对齐到目标的右侧
124+
const targetLocation = entityRectangle.rightTop;
125+
newNode.moveTo(targetLocation);
126+
}
127+
if (direction === Direction.Up) {
128+
const targetLocation = entityRectangle.leftTop.add(new Vector(0, newNode.collisionBox.getRectangle().height));
129+
newNode.moveTo(targetLocation);
130+
}
131+
if (direction === Direction.Down) {
132+
const targetLocation = entityRectangle.leftBottom;
133+
newNode.moveTo(targetLocation);
134+
}
117135
StageHistoryManager.recordStep();
118136
return uuid;
119137
}

0 commit comments

Comments
 (0)