Merge branch 'master' into develop
This commit is contained in:
commit
5294133a58
|
@ -12,7 +12,6 @@ import {
|
|||
import { is } from '../../util/ModelUtil';
|
||||
|
||||
import {
|
||||
every,
|
||||
some
|
||||
} from 'min-dash';
|
||||
|
||||
|
@ -26,6 +25,8 @@ var TARGET_BOUNDS_PADDING = 20;
|
|||
|
||||
var TARGET_CENTER_PADDING = 20;
|
||||
|
||||
var TASK_BOUNDS_PADDING = 10;
|
||||
|
||||
var AXES = [ 'x', 'y' ];
|
||||
|
||||
var abs = Math.abs;
|
||||
|
@ -78,7 +79,7 @@ export default function BpmnConnectSnapping(eventBus, rules) {
|
|||
}
|
||||
|
||||
if (is(target, 'bpmn:Task')) {
|
||||
snapTargetMidOnCenter(event, target);
|
||||
snapToTaskMid(event, target);
|
||||
}
|
||||
|
||||
if (is(source, 'bpmn:BoundaryEvent') && target === source.host) {
|
||||
|
@ -130,21 +131,15 @@ function snapInsideTarget(event, target, padding) {
|
|||
});
|
||||
}
|
||||
|
||||
// snap to target mid if event position in center area
|
||||
function snapTargetMidOnCenter(event, target) {
|
||||
// snap to target mid if event in center
|
||||
function snapToTaskMid(event, target) {
|
||||
var targetMid = mid(target);
|
||||
|
||||
var isCenter = every(AXES, function(axis) {
|
||||
var coordinate = event[axis],
|
||||
matchingTargetDimension = getDimensionForAxis(axis, target);
|
||||
|
||||
return coordinate > target[axis] + TARGET_CENTER_PADDING
|
||||
&& coordinate < target[axis] + matchingTargetDimension - TARGET_CENTER_PADDING;
|
||||
AXES.forEach(function(axis) {
|
||||
if (isCenter(event, target, axis)) {
|
||||
setSnapped(event, axis, targetMid[ axis ]);
|
||||
}
|
||||
});
|
||||
|
||||
if (isCenter) {
|
||||
snapToPosition(event, mid(target));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// snap outside of Boundary Event surroundings
|
||||
|
@ -200,8 +195,13 @@ function getDimensionForAxis(axis, element) {
|
|||
|
||||
function getTargetBoundsPadding(target) {
|
||||
if (is(target, 'bpmn:Task')) {
|
||||
return 10;
|
||||
return TASK_BOUNDS_PADDING;
|
||||
} else {
|
||||
return TARGET_BOUNDS_PADDING;
|
||||
}
|
||||
}
|
||||
|
||||
function isCenter(event, target, axis) {
|
||||
return event[ axis ] > target[ axis ] + TARGET_CENTER_PADDING
|
||||
&& event[ axis ] < target[ axis ] + getDimensionForAxis(axis, target) - TARGET_CENTER_PADDING;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1xakeh4" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.1">
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1xakeh4" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4">
|
||||
<bpmn:collaboration id="Collaboration_1">
|
||||
<bpmn:participant id="Participant_1" processRef="Process_1" />
|
||||
<bpmn:participant id="Participant_2" processRef="Process_2" />
|
||||
<bpmn:participant id="Participant_3" processRef="Process_3" />
|
||||
</bpmn:collaboration>
|
||||
<bpmn:process id="Process_1" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1" />
|
||||
<bpmn:endEvent id="EndEvent_1" />
|
||||
<bpmn:task id="Task_1" />
|
||||
<bpmn:dataObjectReference id="DataObjectReference_1" dataObjectRef="DataObject_16xfc7e" />
|
||||
<bpmn:dataObject id="DataObject_16xfc7e" />
|
||||
<bpmn:exclusiveGateway id="Gateway_1" />
|
||||
<bpmn:subProcess id="SubProcess" />
|
||||
<bpmn:boundaryEvent id="BoundaryEvent" attachedToRef="SubProcess" />
|
||||
<bpmn:boundaryEvent id="BoundaryEventRight" attachedToRef="SubProcess" />
|
||||
<bpmn:startEvent id="StartEvent_1" />
|
||||
<bpmn:task id="Task_1" />
|
||||
</bpmn:process>
|
||||
<bpmn:process id="Process_2" isExecutable="false">
|
||||
<bpmn:task id="Task_2" />
|
||||
|
@ -24,6 +25,10 @@
|
|||
<bpmn:messageEventDefinition />
|
||||
</bpmn:intermediateThrowEvent>
|
||||
</bpmn:process>
|
||||
<bpmn:process id="Process_3" isExecutable="false">
|
||||
<bpmn:startEvent id="StartEvent_2" />
|
||||
<bpmn:task id="Task_3" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">
|
||||
<bpmndi:BPMNShape id="Participant_03743bx_di" bpmnElement="Participant_1" isHorizontal="true">
|
||||
|
@ -65,6 +70,15 @@
|
|||
<bpmndi:BPMNShape id="ExclusiveGateway_1nir8te_di" bpmnElement="Gateway_1" isMarkerVisible="true">
|
||||
<dc:Bounds x="299" y="75" width="50" height="50" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Participant_0echqt5_di" bpmnElement="Participant_3" isHorizontal="true">
|
||||
<dc:Bounds x="32" y="760" width="600" height="250" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="StartEvent_0dv3wii_di" bpmnElement="StartEvent_2">
|
||||
<dc:Bounds x="82" y="877" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_04e4734_di" bpmnElement="Task_3">
|
||||
<dc:Bounds x="170" y="855" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -148,23 +148,23 @@ describe('features/snapping - BpmnConnectSnapping', function() {
|
|||
inject(function(connect, dragging, elementRegistry) {
|
||||
|
||||
// given
|
||||
var startEvent = elementRegistry.get('StartEvent_1'),
|
||||
task = elementRegistry.get('Task_1'),
|
||||
var startEvent = elementRegistry.get('StartEvent_2'),
|
||||
task = elementRegistry.get('Task_3'),
|
||||
taskGfx = elementRegistry.getGraphics(task);
|
||||
|
||||
// when
|
||||
connect.start(canvasEvent({ x: 210, y: 60 }), startEvent);
|
||||
connect.start(canvasEvent({ x: 130, y: 850 }), startEvent);
|
||||
|
||||
dragging.hover({ element: task, gfx: taskGfx });
|
||||
|
||||
dragging.move(canvasEvent({ x: 300, y: 300 }));
|
||||
dragging.move(canvasEvent({ x: 171, y: 893 }));
|
||||
|
||||
dragging.end();
|
||||
|
||||
// then
|
||||
var waypoints = startEvent.outgoing[0].waypoints;
|
||||
|
||||
expect(waypoints[3].y).to.eql(300);
|
||||
expect(waypoints[waypoints.length-1].y).to.eql(895);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue