fix: keep large-plan interactions off the full render path

Issue: #451
User-Visible: yes
This commit is contained in:
Sergey Matyunin
2026-09-04 22:03:45 +03:00
parent 137e160f1a
commit c0d61ca3d2
74 changed files with 21454 additions and 623 deletions
+48
View File
@@ -0,0 +1,48 @@
interface QueuedMove { raf: number; run: () => void }
const moveQueues = new WeakMap<object, Map<string, QueuedMove>>();
/** Keep only the latest raw move of each active gesture between two frames. */
export function queueHouseplanPointerMove(host: object, key: string, run: () => void): void {
let queues = moveQueues.get(host);
if (!queues) {
queues = new Map();
moveQueues.set(host, queues);
}
const queued = queues.get(key);
if (queued) {
queued.run = run;
return;
}
const entry: QueuedMove = { raf: 0, run };
queues.set(key, entry);
if (typeof requestAnimationFrame !== 'function') {
queues.delete(key);
run();
return;
}
entry.raf = requestAnimationFrame(() => {
queues!.delete(key);
entry.run();
});
}
export function flushHouseplanPointerMove(host: object, key: string): void {
const queues = moveQueues.get(host);
const queued = queues?.get(key);
if (!queued) return;
if (queued.raf && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(queued.raf);
queues!.delete(key);
queued.run();
}
export function cancelHouseplanPointerMove(host: object, key?: string): void {
const queues = moveQueues.get(host);
if (!queues) return;
const entries = key ? [...queues].filter(([name]) => name === key) : [...queues];
for (const [name, queued] of entries) {
if (queued.raf && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(queued.raf);
queues.delete(name);
}
if (!queues.size) moveQueues.delete(host);
}