CreateParticipantBehavior.js 871 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { is } from '../../../util/ModelUtil';
  2. var HIGHER_PRIORITY = 1750;
  3. export default function CreateParticipantBehavior(canvas, eventBus, gridSnapping) {
  4. eventBus.on([
  5. 'create.start',
  6. 'shape.move.start'
  7. ], HIGHER_PRIORITY, function(event) {
  8. var context = event.context,
  9. shape = context.shape,
  10. rootElement = canvas.getRootElement();
  11. if (!is(shape, 'bpmn:Participant') ||
  12. !is(rootElement, 'bpmn:Process') ||
  13. !rootElement.children.length) {
  14. return;
  15. }
  16. var createConstraints = context.createConstraints;
  17. if (!createConstraints) {
  18. return;
  19. }
  20. shape.width = gridSnapping.snapValue(shape.width, { min: shape.width });
  21. shape.height = gridSnapping.snapValue(shape.height, { min: shape.height });
  22. });
  23. }
  24. CreateParticipantBehavior.$inject = [
  25. 'canvas',
  26. 'eventBus',
  27. 'gridSnapping'
  28. ];