edge flickring fix while deleting nodes

This commit is contained in:
Feroz Mujawar
2024-11-15 17:56:41 +05:30
parent e98ab130cc
commit ae2c533aca

View File

@@ -318,19 +318,32 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
}); });
// Insert the edges and position the edge labels // Insert the edges and position the edge labels
const edgePositionValues = Object.values(positions.edges);
for (const edge of data4Layout.edges) { for (const edge of data4Layout.edges) {
if (!positions.edges[edge.id]) { if (!positions.edges[edge.id]) {
const startNode = positions.nodes[edge.start]; const startNode = positions.nodes[edge.start];
const endNode = positions.nodes[edge.end]; const endNode = positions.nodes[edge.end];
positions.edges[edge.id] = { // Edge Flickering fix
points: [ const existingEdge = edgePositionValues?.find(
{ x: startNode.x, y: startNode.y }, (value) => value.start === edge.start && value.end === edge.end
{ x: (startNode.x + endNode.x) / 2, y: (startNode.y + endNode.y) / 2 }, );
{ x: endNode.x, y: endNode.y }, if (existingEdge) {
], positions.edges[edge.id] = {
}; ...existingEdge.points,
};
} else {
positions.edges[edge.id] = {
points: [
{ x: startNode.x, y: startNode.y },
{ x: (startNode.x + endNode.x) / 2, y: (startNode.y + endNode.y) / 2 },
{ x: endNode.x, y: endNode.y },
],
start: edge.start,
end: edge.end,
};
}
} }
// edge.points = fixInterSections(positions.edges[edge.id].points, edge.start, edge.end);
edge.points = positions.edges[edge.id].points; edge.points = positions.edges[edge.id].points;
const paths = insertEdge(edgePaths, edge, {}, data4Layout.type, {}, {}, data4Layout.diagramId); const paths = insertEdge(edgePaths, edge, {}, data4Layout.type, {}, {}, data4Layout.diagramId);
paths.updatedPath = paths.originalPath; paths.updatedPath = paths.originalPath;