mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-15 03:53:49 +08:00

* use ES6 import / export * UTILS: export individual utilities * TESTS: localize TestHelper includes BREAKING CHANGE: * all utilities export independent functions * library sources got ported to ES6. You must now use a ES module bundler such as Browserify + babelify or Webpack to consume this library (or parts of it).
44 lines
994 B
JavaScript
44 lines
994 B
JavaScript
'use strict';
|
|
|
|
import inherits from 'inherits';
|
|
|
|
import { is } from '../../../util/ModelUtil';
|
|
|
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
|
|
|
|
export default function AppendBehavior(eventBus, elementFactory, bpmnRules) {
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
// assign correct shape position unless already set
|
|
|
|
this.preExecute('shape.append', function(context) {
|
|
|
|
var source = context.source,
|
|
shape = context.shape;
|
|
|
|
if (!context.position) {
|
|
|
|
if (is(shape, 'bpmn:TextAnnotation')) {
|
|
context.position = {
|
|
x: source.x + source.width / 2 + 75,
|
|
y: source.y - (50) - shape.height / 2
|
|
};
|
|
} else {
|
|
context.position = {
|
|
x: source.x + source.width + 80 + shape.width / 2,
|
|
y: source.y + source.height / 2
|
|
};
|
|
}
|
|
}
|
|
}, true);
|
|
}
|
|
|
|
inherits(AppendBehavior, CommandInterceptor);
|
|
|
|
AppendBehavior.$inject = [
|
|
'eventBus',
|
|
'elementFactory',
|
|
'bpmnRules'
|
|
]; |