all files / bpmn-js/lib/features/modeling/behavior/ ResizeBehavior.js

100% Statements 18/18
100% Branches 12/12
100% Functions 2/2
100% Lines 18/18
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 37 38 39 40 41 42 43 44                              1189× 10× 10× 10× 10×   10×     10×     10×     10×        
import { is } from '../../../util/ModelUtil';
 
import { isExpanded } from '../../../util/DiUtil';
 
import { getParticipantResizeConstraints } from './util/ResizeUtil';
 
var HIGH_PRIORITY = 1500;
 
var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 },
    SUB_PROCESS_MIN_DIMENSIONS = { width: 140, height: 120 },
    TEXT_ANNOTATION_MIN_DIMENSIONS = { width: 50, height: 30 };
 
 
/**
 * Set minimum bounds/resize constraints on resize.
 *
 * @param {EventBus} eventBus
 */
export default function ResizeBehavior(eventBus) {
  eventBus.on('resize.start', HIGH_PRIORITY, function(event) {
    var context = event.context,
        shape = context.shape,
        direction = context.direction,
        balanced = context.balanced;
 
    if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
      context.resizeConstraints = getParticipantResizeConstraints(shape, direction, balanced);
    }
 
    if (is(shape, 'bpmn:Participant')) {
      context.minDimensions = PARTICIPANT_MIN_DIMENSIONS;
    }
 
    if (is(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
      context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
    }
 
    if (is(shape, 'bpmn:TextAnnotation')) {
      context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
    }
  });
}
 
ResizeBehavior.$inject = [ 'eventBus' ];