# all files / Github/bpmn-js/lib/features/grid-snapping/behavior/ CreateParticipantBehavior.js

92.31% Statements 12/13
85.71% Branches 6/7
100% Functions 2/2
92.31% Lines 12/13

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36

    1×

    74×

    6×
    6×
    6×

    6×

    5×

    1×

    1×

    1×
    1×

    1×

     import { is } from '../../../util/ModelUtil';

    var HIGHER_PRIORITY = 1750;

    export default function CreateParticipantBehavior(canvas, eventBus, gridSnapping) {
      eventBus.on([
        'create.start',
        'shape.move.start'
      ], HIGHER_PRIORITY, function(event) {
        var context = event.context,
            shape = context.shape,
            rootElement = canvas.getRootElement();

        if (!is(shape, 'bpmn:Participant') ||
          !is(rootElement, 'bpmn:Process') ||
          !rootElement.children.length) {
          return;
        }

        var createConstraints = context.createConstraints;

        Iif (!createConstraints) {
          return;
        }

        shape.width = gridSnapping.snapValue(shape.width, { min: shape.width });
        shape.height = gridSnapping.snapValue(shape.height, { min: shape.height });
      });
    }

    CreateParticipantBehavior.$inject = [
      'canvas',
      'eventBus',
      'gridSnapping'
    ];