From de996a4030977d8f0ffc3316bb8c4c0ea9b4da00 Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Mon, 12 Aug 2024 15:03:39 +0200 Subject: [PATCH] fix: lane resize constraints for horizontal and vertical lanes Closes #2209 --- .../modeling/behavior/ResizeBehavior.js | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/features/modeling/behavior/ResizeBehavior.js b/lib/features/modeling/behavior/ResizeBehavior.js index 6143f8099d..5747e1eff5 100644 --- a/lib/features/modeling/behavior/ResizeBehavior.js +++ b/lib/features/modeling/behavior/ResizeBehavior.js @@ -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 (!isHorizontalLane) { + 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) { @@ -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); @@ -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); @@ -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); @@ -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