chore(layouting): account for connection(Start|End) hints
Related to bpmn-io/diagram-js#167
This commit is contained in:
parent
d87cbc3b79
commit
f5f05ac011
|
@ -37,8 +37,13 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
|
|||
var manhattanOptions,
|
||||
updatedWaypoints;
|
||||
|
||||
start = getConnectionDocking(waypoints, 0, source, start);
|
||||
end = getConnectionDocking(waypoints, waypoints && waypoints.length - 1, target, end);
|
||||
if (!start) {
|
||||
start = getConnectionDocking(waypoints && waypoints[0], source);
|
||||
}
|
||||
|
||||
if (!end) {
|
||||
end = getConnectionDocking(waypoints && waypoints[waypoints.length - 1], target);
|
||||
}
|
||||
|
||||
// TODO(nikku): support vertical modeling
|
||||
// and invert preferredLayouts accordingly
|
||||
|
@ -47,7 +52,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
|
|||
is(connection, 'bpmn:DataAssociation')) {
|
||||
|
||||
if (waypoints && !isCompensationAssociation(connection)) {
|
||||
return waypoints;
|
||||
return [].concat([ start ], waypoints.slice(1, -1), [ end ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,10 +172,8 @@ function getAttachOrientation(attachedElement) {
|
|||
}
|
||||
|
||||
|
||||
function getConnectionDocking(waypoints, idx, shape, defaultPoint) {
|
||||
var point = waypoints && waypoints[idx];
|
||||
|
||||
return point ? (point.original || point) : (defaultPoint || getMid(shape));
|
||||
function getConnectionDocking(point, shape) {
|
||||
return point ? (point.original || point) : getMid(shape);
|
||||
}
|
||||
|
||||
function isCompensationAssociation(connection) {
|
||||
|
|
Loading…
Reference in New Issue