How to use the diagram-js/lib/layout/LayoutUtil.getOrientation 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 / lib / features / modeling / behavior / AdaptiveLabelPositioningBehavior.js View on Github external
function getTakenHostAlignments(element) {

  var hostElement = element.host,
      elementMid = getMid(element),
      hostOrientation = getOrientation(elementMid, hostElement);

  var freeAlignments;

  // check whether there is a multi-orientation, e.g. 'top-left'
  if (hostOrientation.indexOf('-') >= 0) {
    freeAlignments = hostOrientation.split('-');
  } else {
    freeAlignments = [ hostOrientation ];
  }

  var takenAlignments = ALIGNMENTS.filter(function(alignment) {

    return freeAlignments.indexOf(alignment) === -1;
  });

  return takenAlignments;
github bpmn-io / cmmn-js / lib / features / snapping / CmmnSnappingUtil.js View on Github external
return 'corner';
  }

  // don't snap to bottom left corner
  if (position.x - offset < target.x &&
      position.y + offset > target.y + target.height) {
    return 'corner';
  }

  // don't snap to bottom right corner
  if (position.x + offset > target.x + target.width &&
      position.y + offset > target.y + target.height) {
    return 'corner';
  }

  return getOrientation(position, target, padding);
}
github bpmn-io / bpmn-js / lib / features / snapping / BpmnConnectSnapping.js View on Github external
function snapBoundaryEventLoop(event) {
  var context = event.context,
      source = context.source,
      target = context.target;

  if (isReverse(context)) {
    return;
  }

  var sourceMid = mid(source),
      orientation = getOrientation(sourceMid, target, -10),
      axes = [];

  if (/top|bottom/.test(orientation)) {
    axes.push('x');
  }

  if (/left|right/.test(orientation)) {
    axes.push('y');
  }

  axes.forEach(function(axis) {
    var coordinate = event[ axis ], newCoordinate;

    if (abs(coordinate - sourceMid[ axis ]) < BOUNDARY_TO_HOST_THRESHOLD) {
      if (coordinate > sourceMid[ axis ]) {
        newCoordinate = sourceMid[ axis ] + BOUNDARY_TO_HOST_THRESHOLD;
github bpmn-io / bpmn-js / lib / features / modeling / BpmnLayouter.js View on Github external
function getAttachOrientation(attachedElement) {
  var hostElement = attachedElement.host;

  return getOrientation(getMid(attachedElement), hostElement, ATTACH_ORIENTATION_PADDING);
}
github bpmn-io / bpmn-js / lib / features / auto-place / AutoPlaceUtil.js View on Github external
export function getFlowNodePosition(source, element) {

  var sourceTrbl = asTRBL(source);
  var sourceMid = getMid(source);

  var horizontalDistance = getFlowNodeDistance(source, element);

  var orientation = 'left',
      rowSize = 80,
      margin = 30;

  if (is(source, 'bpmn:BoundaryEvent')) {
    orientation = getOrientation(source, source.host, -25);

    if (orientation.indexOf('top') !== -1) {
      margin *= -1;
    }
  }

  function getVerticalDistance(orient) {
    if (orient.indexOf('top') != -1) {
      return -1 * rowSize;
    } else if (orient.indexOf('bottom') != -1) {
      return rowSize;
    } else {
      return 0;
    }
  }
github bpmn-io / bpmn-js / lib / features / modeling / behavior / AdaptiveLabelPositioningBehavior.js View on Github external
function getApproximateOrientation(p0, p1) {
  return getOrientation(p1, p0, 5);
}
github bpmn-io / bpmn-js / lib / features / auto-place / AutoPlaceUtil.js View on Github external
return find(closure, function(target) {

    if (target === element) {
      return false;
    }

    var orientation = getOrientation(target, bounds, PLACEMENT_DETECTION_PAD);

    return orientation === 'intersect';
  });
}