You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
918 B
36 lines
918 B
import { is } from '../../../util/ModelUtil'; |
|
|
|
var HIGHER_PRIORITY = 1750; |
|
|
|
|
|
export default function GridSnappingParticipantBehavior(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; |
|
|
|
if (!createConstraints) { |
|
return; |
|
} |
|
|
|
shape.width = gridSnapping.snapValue(shape.width, { min: shape.width }); |
|
shape.height = gridSnapping.snapValue(shape.height, { min: shape.height }); |
|
}); |
|
} |
|
|
|
GridSnappingParticipantBehavior.$inject = [ |
|
'canvas', |
|
'eventBus', |
|
'gridSnapping' |
|
]; |