fix: Sequence diagram loop rendering

This commit is contained in:
Sidharth Vinod
2023-09-26 18:36:05 +05:30
parent ad596086ea
commit a3456ec933

View File

@@ -1421,23 +1421,31 @@ const buildMessageModel = function (msg, actors, diagObj) {
return isArrowToRight ? -value : value; return isArrowToRight ? -value : value;
}; };
/** // 3 is max difference for +/- 1
* This is an edge case for the first activation. if (Math.abs(startx - stopx) <= 3) {
* Proper fix would require significant changes. // This is a self reference, so we need to make sure the arrow is drawn correctly
* So, we set an activate flag in the message, and cross check that with isToActivation // There are many checks in the downstream rendering that checks for equality.
* In cases where the message is to an activation that was properly detected, we don't want to move the arrow head // The lines on loops will be off by few pixels, but that's fine for now.
* The activation will not be detected on the first message, so we need to move the arrow head stopx = startx;
*/ } else {
if (msg.activate && !isArrowToActivation) { /**
stopx += adjustValue(conf.activationWidth / 2 - 1); * This is an edge case for the first activation.
} * Proper fix would require significant changes.
* So, we set an activate flag in the message, and cross check that with isToActivation
* In cases where the message is to an activation that was properly detected, we don't want to move the arrow head
* The activation will not be detected on the first message, so we need to move the arrow head
*/
if (msg.activate && !isArrowToActivation) {
stopx += adjustValue(conf.activationWidth / 2 - 1);
}
/** /**
* Shorten the length of arrow at the end and move the marker forward (using refX) to have a clean arrowhead * Shorten the length of arrow at the end and move the marker forward (using refX) to have a clean arrowhead
* This is not required for open arrows that don't have arrowheads * This is not required for open arrows that don't have arrowheads
*/ */
if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) { if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) {
stopx += adjustValue(3); stopx += adjustValue(3);
}
} }
const allBounds = [fromLeft, fromRight, toLeft, toRight]; const allBounds = [fromLeft, fromRight, toLeft, toRight];