mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +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;
|
||||
var head = endNode;
|
||||
|
||||
if (head.intersect && tail.intersect) {
|
||||
points = points.slice(1, edge.points.length - 1);
|
||||
points.unshift(tail.intersect(points[0]));
|
||||
log.debug(
|
||||
'Last point APA12',
|
||||
edge.start,
|
||||
'-->',
|
||||
edge.end,
|
||||
points[points.length - 1],
|
||||
head,
|
||||
head.intersect(points[points.length - 1])
|
||||
);
|
||||
points.push(head.intersect(points[points.length - 1]));
|
||||
if (head.intersect && tail.intersect && points.length > 2) {
|
||||
const initialStartPoint = Object.assign({}, points[0]);
|
||||
const newEnd = head.intersect(points[points.length - 2]);
|
||||
|
||||
const newStart = tail.intersect(points[1]);
|
||||
if (newStart.x && newStart.y) {
|
||||
points.unshift(newStart);
|
||||
} else {
|
||||
points.unshift(initialStartPoint);
|
||||
}
|
||||
if (newEnd.x && newEnd.y) {
|
||||
const lastPoint = points[points.length - 1];
|
||||
if (lastPoint.x !== newEnd.x && lastPoint.y !== newEnd.y) {
|
||||
points.push(newEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (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);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user