BpmnGridSnapping.js 692 B

1234567891011121314151617181920212223242526272829303132
  1. import { isAny } from '../modeling/util/ModelingUtil';
  2. /**
  3. * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
  4. */
  5. /**
  6. * @param {EventBus} eventBus
  7. */
  8. export default function BpmnGridSnapping(eventBus) {
  9. eventBus.on([
  10. 'create.init',
  11. 'shape.move.init'
  12. ], function(event) {
  13. var context = event.context,
  14. shape = event.shape;
  15. if (isAny(shape, [
  16. 'bpmn:Participant',
  17. 'bpmn:SubProcess',
  18. 'bpmn:TextAnnotation'
  19. ])) {
  20. if (!context.gridSnappingContext) {
  21. context.gridSnappingContext = {};
  22. }
  23. context.gridSnappingContext.snapLocation = 'top-left';
  24. }
  25. });
  26. }
  27. BpmnGridSnapping.$inject = [ 'eventBus' ];