mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 23:09:49 +02:00
edge flickring fix while deleting nodes
This commit is contained in:
@@ -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];
|
||||
// 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;
|
||||
|
Reference in New Issue
Block a user