Skip to content

Commit 53e6924

Browse files
committed
[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
1 parent f73ced0 commit 53e6924

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/core/layouts/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,26 @@ const gridEnabledAtom = derivedAtom(layoutStateAtom, (value) => pick(value.quali
117117
gridEnabledAtom.bindEffect((connectedClosenessSettings) => {
118118
if (!connectedClosenessSettings.enabled) return;
119119

120-
// Compute the layout quality metric when node's position changed
120+
//Compute the layout quality metric when node's position changed
121121
const { computeLayoutQualityMetric } = layoutActions;
122122
const fn = debounce(computeLayoutQualityMetric, 300, { leading: true, maxWait: 300 });
123123

124124
computeLayoutQualityMetric();
125125
const sigmaGraph = sigmaGraphAtom.get();
126-
// this event is triggered when sigma data are updated by the derived atom mechanism through a graph import
126+
// this event is triggered when a sync layout has been applied
127127
// this is a custom event
128128
(sigmaGraph as EventEmitter).on("graphImported", fn);
129129

130130
// this event is triggered by user manually changing node positions by dragging node
131-
sigmaGraph.on("nodeAttributesUpdated", fn);
131+
// this is a custom event
132+
(sigmaGraph as EventEmitter).on("nodesDragged", fn);
133+
132134
// this event is triggered by async layout
133135
sigmaGraph.on("eachNodeAttributesUpdated", fn);
134136

135137
return () => {
136138
(sigmaGraph as EventEmitter).off("graphImported", fn);
139+
(sigmaGraph as EventEmitter).off("nodesDragged", fn);
137140
sigmaGraph.off("eachNodeAttributesUpdated", fn);
138-
sigmaGraph.off("nodeAttributesUpdated", fn);
139141
};
140142
});

0 commit comments

Comments
 (0)