function ImportDockingFix(eventBus) {

  function adjustDocking(startPoint, nextPoint, elementMid) {

    var elementTop = {
      x: elementMid.x,
      y: elementMid.y - 50
    };

    var elementLeft = {
      x: elementMid.x - 50,
      y: elementMid.y
    };

    var verticalIntersect = lineIntersect(startPoint, nextPoint, elementMid, elementTop),
        horizontalIntersect = lineIntersect(startPoint, nextPoint, elementMid, elementLeft);

    // original is horizontal or vertical center cross intersection
    var centerIntersect;

    if (verticalIntersect && horizontalIntersect) {
      if (getDistance(verticalIntersect, elementMid) > getDistance(horizontalIntersect, elementMid)) {
        centerIntersect = horizontalIntersect;
      } else {
        centerIntersect = verticalIntersect;
      }
    } else {
      centerIntersect = verticalIntersect || horizontalIntersect;
    }

    startPoint.original = centerIntersect;
  }

  function fixDockings(connection) {
    var waypoints = connection.waypoints;

    adjustDocking(
      waypoints[0],
      waypoints[1],
      getMid(connection.source)
    );

    adjustDocking(
      waypoints[waypoints.length - 1],
      waypoints[waypoints.length - 2],
      getMid(connection.target)
    );
  }

  eventBus.on('bpmnElement.added', function(e) {

    var element = e.element;

    if (element.waypoints) {
      fixDockings(element);
    }
  });
}
/**
 * Fix broken dockings after DI imports.
 *
 * @param {EventBus} eventBus
 */
Fix broken dockings after DI imports.
Fix broken dockings after DI imports .
function ImportDockingFix(eventBus) {
  function adjustDocking(startPoint, nextPoint, elementMid) {
    var elementTop = {
      x: elementMid.x,
      y: elementMid.y - 50
    };
    var elementLeft = {
      x: elementMid.x - 50,
      y: elementMid.y
    };
    var verticalIntersect = lineIntersect(startPoint, nextPoint, elementMid, elementTop),
        horizontalIntersect = lineIntersect(startPoint, nextPoint, elementMid, elementLeft);
    var centerIntersect;
    if (verticalIntersect && horizontalIntersect) {
      if (getDistance(verticalIntersect, elementMid) > getDistance(horizontalIntersect, elementMid)) {
        centerIntersect = horizontalIntersect;
      } else {
        centerIntersect = verticalIntersect;
      }
    } else {
      centerIntersect = verticalIntersect || horizontalIntersect;
    }
    startPoint.original = centerIntersect;
  }
  function fixDockings(connection) {
    var waypoints = connection.waypoints;
    adjustDocking(
      waypoints[0],
      waypoints[1],
      getMid(connection.source)
    );
    adjustDocking(
      waypoints[waypoints.length - 1],
      waypoints[waypoints.length - 2],
      getMid(connection.target)
    );
  }
  eventBus.on('bpmnElement.added', function(e) {
    var element = e.element;
    if (element.waypoints) {
      fixDockings(element);
    }
  });
}
function ImportDockingFix ( eventBus ) { function adjustDocking ( startPoint , nextPoint , elementMid ) { var elementTop = { x : elementMid . x , y : elementMid . y - 50 } ; var elementLeft = { x : elementMid . x - 50 , y : elementMid . y } ; var verticalIntersect = lineIntersect ( startPoint , nextPoint , elementMid , elementTop ) , horizontalIntersect = lineIntersect ( startPoint , nextPoint , elementMid , elementLeft ) ; var centerIntersect ; if ( verticalIntersect && horizontalIntersect ) { if ( getDistance ( verticalIntersect , elementMid ) > getDistance ( horizontalIntersect , elementMid ) ) { centerIntersect = horizontalIntersect ; } else { centerIntersect = verticalIntersect ; } } else { centerIntersect = verticalIntersect || horizontalIntersect ; } startPoint . original = centerIntersect ; } function fixDockings ( connection ) { var waypoints = connection . waypoints ; adjustDocking ( waypoints [ 0 ] , waypoints [ 1 ] , getMid ( connection . source ) ) ; adjustDocking ( waypoints [ waypoints . length - 1 ] , waypoints [ waypoints . length - 2 ] , getMid ( connection . target ) ) ; } eventBus . on ( 'bpmnElement.added' , function ( e ) { var element = e . element ; if ( element . waypoints ) { fixDockings ( element ) ; } } ) ; }
Fix broken dockings after DI imports.
Fix broken dockings after DI imports .
// original is horizontal or vertical center cross intersection