feat: debounce box selection for performance

This commit is contained in:
2026-05-07 21:10:52 +02:00
parent 7d788f7e19
commit 5fa9d36b34
@@ -9,6 +9,7 @@ import { EdgeInteractionManager } from './edge.events';
export class MouseEventManager { export class MouseEventManager {
edgeInteractionManager: EdgeInteractionManager; edgeInteractionManager: EdgeInteractionManager;
private pendingSelectionFrame = false;
constructor( constructor(
private graph: GraphManager, private graph: GraphManager,
@@ -282,6 +283,11 @@ export class MouseEventManager {
if (this.state.boxSelection) { if (this.state.boxSelection) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
if (!this.pendingSelectionFrame) {
this.pendingSelectionFrame = true;
requestAnimationFrame(() => {
this.pendingSelectionFrame = false;
if (!this.state.mouseDown) return;
const mouseD = this.state.projectScreenToWorld( const mouseD = this.state.projectScreenToWorld(
this.state.mouseDown[0], this.state.mouseDown[0],
this.state.mouseDown[1] this.state.mouseDown[1]
@@ -301,6 +307,8 @@ export class MouseEventManager {
this.state.selectedNodes?.delete(node.id); this.state.selectedNodes?.delete(node.id);
} }
} }
});
}
return; return;
} }