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,
|
var manhattanOptions,
|
||||||
updatedWaypoints;
|
updatedWaypoints;
|
||||||
|
|
||||||
start = getConnectionDocking(waypoints, 0, source, start);
|
if (!start) {
|
||||||
end = getConnectionDocking(waypoints, waypoints && waypoints.length - 1, target, end);
|
start = getConnectionDocking(waypoints && waypoints[0], source);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!end) {
|
||||||
|
end = getConnectionDocking(waypoints && waypoints[waypoints.length - 1], target);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(nikku): support vertical modeling
|
// TODO(nikku): support vertical modeling
|
||||||
// and invert preferredLayouts accordingly
|
// and invert preferredLayouts accordingly
|
||||||
|
@ -47,7 +52,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
|
||||||
is(connection, 'bpmn:DataAssociation')) {
|
is(connection, 'bpmn:DataAssociation')) {
|
||||||
|
|
||||||
if (waypoints && !isCompensationAssociation(connection)) {
|
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) {
|
function getConnectionDocking(point, shape) {
|
||||||
var point = waypoints && waypoints[idx];
|
return point ? (point.original || point) : getMid(shape);
|
||||||
|
|
||||||
return point ? (point.original || point) : (defaultPoint || getMid(shape));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCompensationAssociation(connection) {
|
function isCompensationAssociation(connection) {
|
||||||
|
|
Loading…
Reference in New Issue