mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-02-04 07:13:25 +08:00
#5237 Fix for weird line intersection
This commit is contained in:
parent
53bff117aa
commit
19d46fc823
@ -429,19 +429,22 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
|
|||||||
const tail = startNode;
|
const tail = startNode;
|
||||||
var head = endNode;
|
var head = endNode;
|
||||||
|
|
||||||
if (head.intersect && tail.intersect) {
|
if (head.intersect && tail.intersect && points.length > 2) {
|
||||||
points = points.slice(1, edge.points.length - 1);
|
const initialStartPoint = Object.assign({}, points[0]);
|
||||||
points.unshift(tail.intersect(points[0]));
|
const newEnd = head.intersect(points[points.length - 2]);
|
||||||
log.debug(
|
|
||||||
'Last point APA12',
|
const newStart = tail.intersect(points[1]);
|
||||||
edge.start,
|
if (newStart.x && newStart.y) {
|
||||||
'-->',
|
points.unshift(newStart);
|
||||||
edge.end,
|
} else {
|
||||||
points[points.length - 1],
|
points.unshift(initialStartPoint);
|
||||||
head,
|
}
|
||||||
head.intersect(points[points.length - 1])
|
if (newEnd.x && newEnd.y) {
|
||||||
);
|
const lastPoint = points[points.length - 1];
|
||||||
points.push(head.intersect(points[points.length - 1]));
|
if (lastPoint.x !== newEnd.x && lastPoint.y !== newEnd.y) {
|
||||||
|
points.push(newEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (edge.toCluster) {
|
if (edge.toCluster) {
|
||||||
log.info('to cluster abc88', clusterDb.get(edge.toCluster));
|
log.info('to cluster abc88', clusterDb.get(edge.toCluster));
|
||||||
|
@ -63,7 +63,14 @@ export const question = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
|||||||
updateNodeBounds(node, polygon);
|
updateNodeBounds(node, polygon);
|
||||||
|
|
||||||
node.intersect = function (point) {
|
node.intersect = function (point) {
|
||||||
log.info('Intersect called SPLIT');
|
log.debug(
|
||||||
|
'APA12 Intersect called SPLIT\npoint:',
|
||||||
|
point,
|
||||||
|
'\nnode:\n',
|
||||||
|
node,
|
||||||
|
'\nres:',
|
||||||
|
intersect.polygon(node, points, point)
|
||||||
|
);
|
||||||
return intersect.polygon(node, points, point);
|
return intersect.polygon(node, points, point);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user