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,6 +1421,13 @@ const buildMessageModel = function (msg, actors, diagObj) {
return isArrowToRight ? -value : value; return isArrowToRight ? -value : value;
}; };
// 3 is max difference for +/- 1
if (Math.abs(startx - stopx) <= 3) {
// This is a self reference, so we need to make sure the arrow is drawn correctly
// There are many checks in the downstream rendering that checks for equality.
// The lines on loops will be off by few pixels, but that's fine for now.
stopx = startx;
} else {
/** /**
* This is an edge case for the first activation. * This is an edge case for the first activation.
* Proper fix would require significant changes. * Proper fix would require significant changes.
@@ -1439,6 +1446,7 @@ const buildMessageModel = function (msg, actors, diagObj) {
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];
const boundedWidth = Math.abs(startx - stopx); const boundedWidth = Math.abs(startx - stopx);