fix(editor): сохранять позицию кнопки при отмене Resize (#645)

Транзитная геометрия Resize теперь только вычисляет центр для текущего кадра и не удаляет сессионную позицию. Окончательная геометрия по-прежнему очищает точку, если она действительно вышла за комнату.

Issue: #645
User-Visible: yes
This commit is contained in:
Sergey Matyunin
2026-09-25 10:15:34 +03:00
parent 449438fb20
commit f293c6e9dc
75 changed files with 830 additions and 752 deletions
+1 -1
View File
@@ -12005,7 +12005,7 @@ export class HouseplanCard extends LitElement {
private _renderRoomGear(
r: RoomCfg, space: SpaceModel, view: { x: number; y: number; w: number; h: number },
): TemplateResult | typeof nothing {
return this._editorRuntimeOrThrow()._renderRoomGear(r, space, view);
return this._editorRuntimeOrThrow()._renderRoomGear(r, space, view, this._resize.dragging);
}
private _renderRoomLabel(
+4 -3
View File
@@ -3432,7 +3432,7 @@ public _rszEdgeLabels(
const poly = res.polys[id] || rooms.find((r) => r.id === id)!.poly;
const room = space?.rooms.find((candidate) => candidate.id === id);
const gearCenter = room
? (this.roomGear.center(room, poly, space!.id) || poleOfInaccessibility(poly))
? (this.roomGear.previewCenter(room, poly, space!.id) || poleOfInaccessibility(poly))
: poleOfInaccessibility(poly);
// The preview is already the active render model. Reuse the same shared
// masonry union + contour cache that the following render consumes;
@@ -10275,11 +10275,12 @@ public _rlResizeUp(): void {
public _cancelRoomGearForMultitouch(): boolean { return this.roomGear.cancelForMultitouch(); }
public _renderRoomGear(
r: RoomCfg, space: SpaceModel, view: { x: number; y: number; w: number; h: number },
r: RoomCfg, space: SpaceModel, view: { x: number; y: number; w: number; h: number }, preview: boolean,
): TemplateResult | typeof nothing {
if (!r.id) return nothing;
this.roomGear.adoptPlan(space);
const c = this.roomGear.center(r, roomPoly(r), space.id);
const polygon = roomPoly(r);
const c = preview ? this.roomGear.previewCenter(r, polygon, space.id) : this.roomGear.center(r, polygon, space.id);
if (!c) return nothing;
const left = ((c[0] - view.x) / view.w) * 100;
const top = ((c[1] - view.y) / view.h) * 100;
+13
View File
@@ -200,6 +200,19 @@ export class RoomGearDragController {
return resolved.point;
}
/**
* Resolve against a transient geometry preview without pruning the saved
* session position. A cancelled preview must not become a permanent move.
*/
public previewCenter(
room: RoomCfg, polygonOverride?: number[][] | null, spaceId = this.input.spaceId(),
): RoomGearPoint | null {
if (!room.id) return null;
return resolveRoomGearCenter(
room, this.positions.get(this.key(room.id, spaceId)), polygonOverride,
).point;
}
public dragging(key: string): boolean { return this.drag?.key === key; }
public reset(): void {