How to use the diagram-js/lib/util/Elements.getBBox function in diagram-js

To help you get started, we’ve selected a few diagram-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpmn-io / bpmn-js / test / spec / features / modeling / behavior / CreateParticipantBehaviorSpec.js View on Github external
it('should constrain ' + JSON.stringify(position), inject(function(dragging) {

            // when
            dragging.move(canvasEvent(position));

            dragging.end();

            // then
            expectBoundsWithin(
              asTRBL(getBBox(participant.children)),
              asTRBL(getBBox(participant)),
              padding
            );
          }));
github bpmn-io / bpmn-js / test / spec / features / editor-actions / BpmnEditorActionsSpec.js View on Github external
it('should move to origin', inject(function(editorActions) {

          // given
          var elements = editorActions.trigger('selectElements'),
              boundingBox;

          // when
          editorActions.trigger('moveToOrigin');

          boundingBox = getBBox(elements);

          // then
          expect(pick(boundingBox, [ 'x', 'y' ])).to.eql({ x: 0, y: 0 });
        }));
github bpmn-io / bpmn-js / test / spec / features / modeling / behavior / CreateParticipantBehaviorSpec.js View on Github external
it('should constrain ' + JSON.stringify(position), inject(function(dragging) {

            // when
            dragging.move(canvasEvent(position));

            dragging.end();

            // then
            expectBoundsWithin(
              asTRBL(getBBox(participant.children)),
              asTRBL(getBBox(participant)),
              padding
            );
          }));
github bpmn-io / bpmn-js / lib / features / auto-resize / AutoResize.js View on Github external
function expand(elements, target) {

    if (typeof target === 'string') {
      target = elementRegistry.get(target);
    }

    var bbox = getBoundingBox(elements),
        canExpand = true;

    if (!is(target, 'bpmn:Participant') && !is(target, 'bpmn:Lane') && !(is(target, 'bpmn:SubProcess'))) {
      return;
    }

    forEach(elements, function(element) {

      if (is(element, 'bpmn:Lane') || element.labelTarget) {
        canExpand = false;
        return;
      }
    });

    if (!canExpand) {
      return;
github bpmn-io / bpmn-js / lib / features / editor-actions / BpmnEditorActions.js View on Github external
this._registerAction('moveToOrigin', function() {
      var rootElement = canvas.getRootElement(),
          boundingBox,
          elements;

      if (is(rootElement, 'bpmn:Collaboration')) {
        elements = elementRegistry.filter(function(element) {
          return is(element.parent, 'bpmn:Collaboration');
        });
      } else {
        elements = elementRegistry.filter(function(element) {
          return element !== rootElement && !is(element.parent, 'bpmn:SubProcess');
        });
      }

      boundingBox = getBBox(elements);

      modeling.moveElements(
        elements,
        { x: -boundingBox.x, y: -boundingBox.y },
        rootElement
      );
    });
  }