Skip to content

Commit

Permalink
fix: lane resize constraints for horizontal and vertical lanes
Browse files Browse the repository at this point in the history
Closes #2209
  • Loading branch information
abdul99ahad authored and nikku committed Sep 9, 2024
1 parent 988cb29 commit 7a137cc
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions lib/features/modeling/behavior/ResizeBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,25 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala

var otherTrbl = asTRBL(other);

if (/n/.test(resizeDirection)) {
if (isHorizontalLane && otherTrbl.top < (laneTrbl.top - 10)) {
// lane flags
if (isHorizontalLane) {
if (otherTrbl.top < (laneTrbl.top - 10)) {
isFirst = false;
}
if (otherTrbl.bottom > (laneTrbl.bottom + 10)) {
isLast = false;
}
}
else {
if (otherTrbl.left < (laneTrbl.left - 10)) {
isFirst = false;
}
if (otherTrbl.right > (laneTrbl.right + 10)) {
isLast = false;
}
}

if (/n/.test(resizeDirection)) {

// max top size (based on next element)
if (balanced && abs(laneTrbl.top - otherTrbl.bottom) < 10) {
Expand All @@ -178,10 +193,6 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala

if (/e/.test(resizeDirection)) {

if (!isHorizontalLane && otherTrbl.right > (laneTrbl.right + 10)) {
isLast = false;
}

// max right size (based on previous element)
if (balanced && abs(laneTrbl.right - otherTrbl.left) < 10) {
addMin(maxTrbl, 'right', otherTrbl.right - minDimensions.width);
Expand All @@ -195,10 +206,6 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala

if (/s/.test(resizeDirection)) {

if (isHorizontalLane && otherTrbl.bottom > (laneTrbl.bottom + 10)) {
isLast = false;
}

// max bottom size (based on previous element)
if (balanced && abs(laneTrbl.bottom - otherTrbl.top) < 10) {
addMin(maxTrbl, 'bottom', otherTrbl.bottom - minDimensions.height);
Expand All @@ -212,10 +219,6 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala

if (/w/.test(resizeDirection)) {

if (!isHorizontalLane && otherTrbl.left < (laneTrbl.left - 10)) {
isFirst = false;
}

// max left size (based on next element)
if (balanced && abs(laneTrbl.left - otherTrbl.right) < 10) {
addMax(maxTrbl, 'left', otherTrbl.left + minDimensions.width);
Expand All @@ -239,23 +242,26 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala

var flowElementTrbl = asTRBL(flowElement);

if (isFirst && /n/.test(resizeDirection)) {
// vertical lane will resize from top with respect to flow element irrespective of first or last lane
if (/n/.test(resizeDirection) && (!isHorizontalLane || isFirst)) {
addMin(minTrbl, 'top', flowElementTrbl.top - padding.top);
}

if (isLast && /e/.test(resizeDirection)) {
// horizonal lane will resize from right with respect to flow element irrespective of first or last lane
if (/e/.test(resizeDirection) && (isHorizontalLane || isLast)) {
addMax(minTrbl, 'right', flowElementTrbl.right + padding.right);
}

if (isLast && /s/.test(resizeDirection)) {
// vertical lane will resize from bottom with respect to flow element irrespective of first or last lane
if (/s/.test(resizeDirection) && (!isHorizontalLane || isLast)) {
addMax(minTrbl, 'bottom', flowElementTrbl.bottom + padding.bottom);
}

if (isFirst && /w/.test(resizeDirection)) {
// horizonal lane will resize from left with respect to flow element irrespective of first or last lane
if (/w/.test(resizeDirection) && (isHorizontalLane || isFirst)) {
addMin(minTrbl, 'left', flowElementTrbl.left - padding.left);
}
});

return {
min: minTrbl,
max: maxTrbl
Expand Down

0 comments on commit 7a137cc

Please sign in to comment.