BpmnSpaceTool.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import inherits from 'inherits-browser';
  2. import SpaceTool from 'diagram-js/lib/features/space-tool/SpaceTool';
  3. import { getBusinessObject, is } from '../../util/ModelUtil';
  4. /**
  5. * @typedef {import('didi').Injector} Injector
  6. *
  7. * @typedef {import('../../model/Types').Shape} Shape
  8. *
  9. * @typedef {import('diagram-js/lib/util/Types').Axis} Axis
  10. * @typedef {import('diagram-js/lib/util/Types').Point} Point
  11. */
  12. /**
  13. * @param {Injector} injector
  14. */
  15. export default function BpmnSpaceTool(injector) {
  16. injector.invoke(SpaceTool, this);
  17. }
  18. BpmnSpaceTool.$inject = [
  19. 'injector'
  20. ];
  21. inherits(BpmnSpaceTool, SpaceTool);
  22. /**
  23. * @param {Shape[]} elements
  24. * @param {Axis} axis
  25. * @param {Point} delta
  26. * @param {number} start
  27. *
  28. * @return {Object}
  29. */
  30. BpmnSpaceTool.prototype.calculateAdjustments = function(elements, axis, delta, start) {
  31. var adjustments = SpaceTool.prototype.calculateAdjustments.call(this, elements, axis, delta, start);
  32. // do not resize:
  33. //
  34. // * text annotations (horizontally/vertically)
  35. // * empty pools (vertically)
  36. adjustments.resizingShapes = adjustments.resizingShapes.filter(function(shape) {
  37. if (is(shape, 'bpmn:TextAnnotation')) {
  38. return false;
  39. }
  40. if (axis === 'y' && isCollapsedPool(shape)) {
  41. return false;
  42. }
  43. return true;
  44. });
  45. return adjustments;
  46. };
  47. // helpers ///////////
  48. function isCollapsedPool(shape) {
  49. return is(shape, 'bpmn:Participant') && !getBusinessObject(shape).processRef;
  50. }