diff --git a/lib/features/auto-place/AutoPlaceUtil.js b/lib/features/auto-place/AutoPlaceUtil.js index dda65154..6bbf5dc4 100644 --- a/lib/features/auto-place/AutoPlaceUtil.js +++ b/lib/features/auto-place/AutoPlaceUtil.js @@ -37,21 +37,24 @@ export function getFlowNodePosition(source, element) { if (is(source, 'bpmn:BoundaryEvent')) { orientation = getOrientation(source, source.host, -25); - if (orientation === 'top') { + if (orientation.indexOf('top') !== -1) { margin *= -1; } } - var verticalDistances = { - left: 0, - right: 0, - top: -1 * rowSize, - bottom: rowSize - }; + function getVerticalDistance(orient) { + if (orient.indexOf('top') != -1) { + return -1 * rowSize; + } else if (orient.indexOf('bottom') != -1) { + return rowSize; + } else { + return 0; + } + } var position = { x: sourceTrbl.right + horizontalDistance + element.width / 2, - y: sourceMid.y + verticalDistances[orientation] + y: sourceMid.y + getVerticalDistance(orientation) }; var escapeDirection = { diff --git a/test/spec/features/auto-place/AutoPlace.boundary-events.bpmn b/test/spec/features/auto-place/AutoPlace.boundary-events.bpmn index 56e8d8fd..0b482023 100644 --- a/test/spec/features/auto-place/AutoPlace.boundary-events.bpmn +++ b/test/spec/features/auto-place/AutoPlace.boundary-events.bpmn @@ -11,6 +11,7 @@ + @@ -29,7 +30,7 @@ - + @@ -45,6 +46,12 @@ + + + + + + diff --git a/test/spec/features/auto-place/AutoPlaceSpec.js b/test/spec/features/auto-place/AutoPlaceSpec.js index 2352cccd..8931bdcd 100644 --- a/test/spec/features/auto-place/AutoPlaceSpec.js +++ b/test/spec/features/auto-place/AutoPlaceSpec.js @@ -216,6 +216,11 @@ describe('features/auto-place', function() { expectedBounds: { x: 242, y: -27, width: 100, height: 80 } })); + it('should place top right of BOUNDARY_TOP_RIGHT without infinite loop', autoPlace({ + element: 'bpmn:Task', + behind: 'BOUNDARY_TOP_RIGHT', + expectedBounds: { x: 473, y: -27, width: 100, height: 80 } + })); it('should place top right of BOUNDARY_SUBPROCESS_TOP', autoPlace({ element: 'bpmn:Task',