From 61249b0887d77ffb0fc255b9695ba043b87c7243 Mon Sep 17 00:00:00 2001 From: Ivan Danilov Date: Wed, 13 May 2020 21:42:29 -0700 Subject: [PATCH] Fixed SequenceDiagram over note horizontal position Previous expression with noteWidth does not make sense as noteWidth is not used in case of note over two participants - forceWidth is used instead. It tried to be symmetrical over cases A,B and B,A but failed. Can be seen with messages over conf.width size (cannot reproduce in the live editor as it seems to use not the last version where the code does not use noteWidth). The changed code explicitly calculates which of the actors is the "left" one and starts rendering half margin to the left of its cetral line. --- src/diagrams/sequence/sequenceRenderer.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/diagrams/sequence/sequenceRenderer.js b/src/diagrams/sequence/sequenceRenderer.js index 18177516d..ca5e448a0 100644 --- a/src/diagrams/sequence/sequenceRenderer.js +++ b/src/diagrams/sequence/sequenceRenderer.js @@ -639,14 +639,12 @@ export const draw = function(text, id) { } else { // Multi-actor over forceWidth = Math.abs(startx - stopx) + conf.actorMargin; + let x = + startx < stopx + ? startx + (actors[msg.from].width - conf.actorMargin) / 2 + : stopx + (actors[msg.to].width - conf.actorMargin) / 2; - drawNote( - diagram, - (startx + stopx + noteWidth - forceWidth) / 2, - bounds.getVerticalPos(), - msg, - forceWidth - ); + drawNote(diagram, x, bounds.getVerticalPos(), msg, forceWidth); } break; case parser.yy.LINETYPE.ACTIVE_START: