fix(cockpit): only a ship's double-click remembers where it began

The first press's picture of the track is there because a click on a
selected ship re-centres the camera. It applied to followed aircraft too,
widening their double-click hit area to wherever the aircraft was drawn
as the gesture began. Aircraft are back to the hit where they are drawn.
This commit is contained in:
Sameh Khamis committed 2026-11-08 14:09:17 -08:00
1 parent bbe33b48c7
commit 620a18608e
2 files changed
+29 -1

No files matched your search

+7 -1
View File
@@ -65,7 +65,7 @@ function subjectCanvasPosition() {
}
/**
* Note where the followed track is drawn as a press begins, for a
* Note where the selected ship is drawn as a press begins, for a
* double-click whose first click moves it. The second press of the gesture
* keeps the first one's picture: by then the first click may have moved it.
* @param {number} [nowMs]
@@ -74,6 +74,12 @@ export function onScenePointerDown(nowMs = performance.now()) {
if (this.active || this.destroyed) return;
const start = this.doubleClickStart;
if (start && nowMs - start.atMs <= DOUBLE_CLICK_MEMORY_MS) return;
// Only a ship moves under its own click (selecting it re-centres the
// camera); a followed aircraft stays put, so its hit area stays its own.
if (this.resolveEntryKind() !== 'vessel') {
this.doubleClickStart = null;
return;
}
const at = subjectCanvasPosition.call(this);
this.doubleClickStart = at ? { x: at.x, y: at.y, atMs: nowMs } : null;
}