From 53e6924617d4ab09083d02b23e9f55194e88a2da Mon Sep 17 00:00:00 2001 From: Paul Girard Date: Mon, 7 Oct 2024 15:28:47 +0200 Subject: [PATCH] [layout] reduce quality metric impact review event which triggers layout metric calculation the updateNode event scope was too large so we created a nodesDragged one --- src/core/layouts/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/layouts/index.ts b/src/core/layouts/index.ts index 232b4c0..eec07cb 100644 --- a/src/core/layouts/index.ts +++ b/src/core/layouts/index.ts @@ -117,24 +117,26 @@ const gridEnabledAtom = derivedAtom(layoutStateAtom, (value) => pick(value.quali gridEnabledAtom.bindEffect((connectedClosenessSettings) => { if (!connectedClosenessSettings.enabled) return; - // Compute the layout quality metric when node's position changed + //Compute the layout quality metric when node's position changed const { computeLayoutQualityMetric } = layoutActions; const fn = debounce(computeLayoutQualityMetric, 300, { leading: true, maxWait: 300 }); computeLayoutQualityMetric(); const sigmaGraph = sigmaGraphAtom.get(); - // this event is triggered when sigma data are updated by the derived atom mechanism through a graph import + // this event is triggered when a sync layout has been applied // this is a custom event (sigmaGraph as EventEmitter).on("graphImported", fn); // this event is triggered by user manually changing node positions by dragging node - sigmaGraph.on("nodeAttributesUpdated", fn); + // this is a custom event + (sigmaGraph as EventEmitter).on("nodesDragged", fn); + // this event is triggered by async layout sigmaGraph.on("eachNodeAttributesUpdated", fn); return () => { (sigmaGraph as EventEmitter).off("graphImported", fn); + (sigmaGraph as EventEmitter).off("nodesDragged", fn); sigmaGraph.off("eachNodeAttributesUpdated", fn); - sigmaGraph.off("nodeAttributesUpdated", fn); }; });