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
const edgePositionValues = Object.values(positions.edges);
for (const edge of data4Layout.edges) {
if (!positions.edges[edge.id]) {
const startNode = positions.nodes[edge.start];
const endNode = positions.nodes[edge.end];
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 },
],
};
// Edge Flickering fix
const existingEdge = edgePositionValues?.find(
(value) => value.start === edge.start && value.end === edge.end
);
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;
const paths = insertEdge(edgePaths, edge, {}, data4Layout.type, {}, {}, data4Layout.diagramId);
paths.updatedPath = paths.originalPath;