How to use the diagram-js/lib/features/resize/ResizeUtil.addPadding 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 / cmmn-js / lib / features / modeling / behavior / ResizeCasePlanModelBehavior.js View on Github external
function computeChildrenBBox(shape, padding) {
  // grab all the children that are part of the
  // parents children box
  var elements = filter(shape.children, function(element) {
    return isBBoxChild(shape, element);
  });

  if (elements.length) {
    return ResizeUtil.addPadding(getBBox(elements), padding);
  }
}
github bptlab / chor-js / lib / features / resize / ChoreoResize.js View on Github external
minDimensions = context.minDimensions || {
      width: 100,
      height: topBandsHeight + bottomBandsHeight + 40
    };

    // get children we want to factor in in determining the bounds (only when not collapsed)
    let childrenBounds;
    if (!shape.collapsed) {
      childrenBounds = getChildrenBBox(shape);
      if (childrenBounds) {
        // add padding from context
        childrenBounds = addPadding(childrenBounds, context.childrenBoxPadding);

        // add padding for the bands
        childrenBounds = addPadding(childrenBounds, {
          left: 0,
          right: 0,
          top: heightOfTopBands(shape),
          bottom: heightOfBottomBands(shape)
        });
      }
    }

    return getMinResizeBounds(direction, shape, minDimensions, childrenBounds);
  }
  return Resize.prototype.computeMinResizeBox.call(this, context);
};
github bptlab / chor-js / lib / features / resize / ChoreoResize.js View on Github external
if (is(shape, 'bpmn:ChoreographyActivity')) {
    let topBandsHeight = heightOfTopBands(shape);
    let bottomBandsHeight = heightOfBottomBands(shape);

    minDimensions = context.minDimensions || {
      width: 100,
      height: topBandsHeight + bottomBandsHeight + 40
    };

    // get children we want to factor in in determining the bounds (only when not collapsed)
    let childrenBounds;
    if (!shape.collapsed) {
      childrenBounds = getChildrenBBox(shape);
      if (childrenBounds) {
        // add padding from context
        childrenBounds = addPadding(childrenBounds, context.childrenBoxPadding);

        // add padding for the bands
        childrenBounds = addPadding(childrenBounds, {
          left: 0,
          right: 0,
          top: heightOfTopBands(shape),
          bottom: heightOfBottomBands(shape)
        });
      }
    }

    return getMinResizeBounds(direction, shape, minDimensions, childrenBounds);
  }
  return Resize.prototype.computeMinResizeBox.call(this, context);
};
github bptlab / chor-js / lib / features / modeling / behavior / ToggleChoreoCollapseBehavior.js View on Github external
function expandedBounds(shape, defaultSize) {
  let bounds = getChildrenBBox(shape);
  if (bounds) {
    bounds = addPadding(bounds, {
      left: 0,
      right: 0,
      top: heightOfTopBands(shape),
      bottom: heightOfBottomBands(shape)
    });
    bounds = addPadding(bounds, 20);
    return bounds;
  } else {
    return {
      x: shape.x + (shape.width - defaultSize.width) / 2,
      y: shape.y + (shape.height - defaultSize.height) / 2,
      width: defaultSize.width,
      height: defaultSize.height
    };
  }
}
github bptlab / chor-js / lib / features / modeling / behavior / ToggleChoreoCollapseBehavior.js View on Github external
function expandedBounds(shape, defaultSize) {
  let bounds = getChildrenBBox(shape);
  if (bounds) {
    bounds = addPadding(bounds, {
      left: 0,
      right: 0,
      top: heightOfTopBands(shape),
      bottom: heightOfBottomBands(shape)
    });
    bounds = addPadding(bounds, 20);
    return bounds;
  } else {
    return {
      x: shape.x + (shape.width - defaultSize.width) / 2,
      y: shape.y + (shape.height - defaultSize.height) / 2,
      width: defaultSize.width,
      height: defaultSize.height
    };
  }
}