chore: refactored code

on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
omkarht
2025-08-06 18:56:58 +05:30
parent 3e5d2db514
commit bd47c57eaf

View File

@@ -286,28 +286,35 @@ const drawCentralConnection = function (
msg: any, msg: any,
msgModel: any, msgModel: any,
diagObj: Diagram, diagObj: Diagram,
startx, startx: number,
stopx, stopx: number,
lineStartY lineStartY: number
) { ) {
const actors = diagObj.db.getActors();
const [fromLeft] = activationBounds(msg.from, actors);
const [toLeft] = activationBounds(msg.to, actors);
const isArrowToRight = fromLeft <= toLeft;
const g = elem.append('g'); const g = elem.append('g');
const circle = g.append('circle');
circle.attr( const drawCircle = (cx: number) => {
'cx', g.append('circle')
msg.centralConnection === diagObj.db.LINETYPE.CENTRAL_CONNECTION ? stopx + 7.5 : startx - 5 .attr('cx', cx)
); .attr('cy', lineStartY)
// circle.attr('cx',x); .attr('r', 5)
circle.attr('cy', lineStartY); .attr('width', 10)
circle.attr('r', 5); .attr('height', 10);
circle.attr('width', 10); };
circle.attr('height', 10);
if (msg.centralConnection === diagObj.db.LINETYPE.CENTRAL_CONNECTION_DUAL) { if (msg.centralConnection === diagObj.db.LINETYPE.CENTRAL_CONNECTION) {
const circle = g.append('circle'); const cx = isArrowToRight ? stopx + 8 : stopx - 8;
circle.attr('cx', stopx + 7.5); drawCircle(cx);
circle.attr('cy', lineStartY); } else if (msg.centralConnection === diagObj.db.LINETYPE.CENTRAL_CONNECTION_DUAL) {
circle.attr('r', 5); const offset = isArrowToRight ? 8 : -8;
circle.attr('width', 10); drawCircle(stopx + offset);
circle.attr('height', 10); drawCircle(startx - 2.75); // second circle (near start)
} else {
drawCircle(startx - 2.75);
} }
}; };