chore(auto-place): adjust to new auto place API
This commit is contained in:
parent
e03a4b2c59
commit
8d583dd91f
|
@ -8,7 +8,8 @@ import {
|
||||||
} from 'diagram-js/lib/layout/LayoutUtil';
|
} from 'diagram-js/lib/layout/LayoutUtil';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
deconflictPosition,
|
findFreePosition,
|
||||||
|
generateGetNextPosition,
|
||||||
getConnectedDistance
|
getConnectedDistance
|
||||||
} from 'diagram-js/lib/features/auto-place/AutoPlaceUtil';
|
} from 'diagram-js/lib/features/auto-place/AutoPlaceUtil';
|
||||||
|
|
||||||
|
@ -46,13 +47,15 @@ export function getFlowNodePosition(source, element) {
|
||||||
var sourceTrbl = asTRBL(source);
|
var sourceTrbl = asTRBL(source);
|
||||||
var sourceMid = getMid(source);
|
var sourceMid = getMid(source);
|
||||||
|
|
||||||
var horizontalDistance = getConnectedDistance(source, 'x', function(connection) {
|
var horizontalDistance = getConnectedDistance(source, {
|
||||||
|
filter: function(connection) {
|
||||||
return is(connection, 'bpmn:SequenceFlow');
|
return is(connection, 'bpmn:SequenceFlow');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var orientation = 'left',
|
var margin = 30,
|
||||||
rowSize = 80,
|
minDistance = 80,
|
||||||
margin = 30;
|
orientation = 'left';
|
||||||
|
|
||||||
if (is(source, 'bpmn:BoundaryEvent')) {
|
if (is(source, 'bpmn:BoundaryEvent')) {
|
||||||
orientation = getOrientation(source, source.host, -25);
|
orientation = getOrientation(source, source.host, -25);
|
||||||
|
@ -62,31 +65,32 @@ export function getFlowNodePosition(source, element) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVerticalDistance(orient) {
|
var position = {
|
||||||
if (orient.indexOf('top') != -1) {
|
x: sourceTrbl.right + horizontalDistance + element.width / 2,
|
||||||
return -1 * rowSize;
|
y: sourceMid.y + getVerticalDistance(orientation, minDistance)
|
||||||
} else if (orient.indexOf('bottom') != -1) {
|
};
|
||||||
return rowSize;
|
|
||||||
|
var nextPositionDirection = {
|
||||||
|
y: {
|
||||||
|
margin: margin,
|
||||||
|
minDistance: minDistance
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return findFreePosition(source, element, position, generateGetNextPosition(nextPositionDirection));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getVerticalDistance(orientation, minDistance) {
|
||||||
|
if (orientation.indexOf('top') != -1) {
|
||||||
|
return -1 * minDistance;
|
||||||
|
} else if (orientation.indexOf('bottom') != -1) {
|
||||||
|
return minDistance;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = {
|
|
||||||
x: sourceTrbl.right + horizontalDistance + element.width / 2,
|
|
||||||
y: sourceMid.y + getVerticalDistance(orientation)
|
|
||||||
};
|
|
||||||
|
|
||||||
var escapeDirection = {
|
|
||||||
y: {
|
|
||||||
margin: margin,
|
|
||||||
rowSize: rowSize
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return deconflictPosition(source, element, position, escapeDirection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always try to place text annotations top right of source.
|
* Always try to place text annotations top right of source.
|
||||||
|
@ -100,14 +104,14 @@ export function getTextAnnotationPosition(source, element) {
|
||||||
y: sourceTrbl.top - 50 - element.height / 2
|
y: sourceTrbl.top - 50 - element.height / 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var escapeDirection = {
|
var nextPositionDirection = {
|
||||||
y: {
|
y: {
|
||||||
margin: -30,
|
margin: -30,
|
||||||
rowSize: 20
|
minDistance: 20
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return deconflictPosition(source, element, position, escapeDirection);
|
return findFreePosition(source, element, position, generateGetNextPosition(nextPositionDirection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,12 +127,12 @@ export function getDataElementPosition(source, element) {
|
||||||
y: sourceTrbl.bottom + 40 + element.width / 2
|
y: sourceTrbl.bottom + 40 + element.width / 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var escapeDirection = {
|
var nextPositionDirection = {
|
||||||
x: {
|
x: {
|
||||||
margin: 30,
|
margin: 30,
|
||||||
rowSize: 30
|
minDistance: 30
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return deconflictPosition(source, element, position, escapeDirection);
|
return findFreePosition(source, element, position, generateGetNextPosition(nextPositionDirection));
|
||||||
}
|
}
|
Loading…
Reference in New Issue