rect.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.rect = void 0;
  4. const x6_common_1 = require("@antv/x6-common");
  5. const bbox_1 = require("./bbox");
  6. const util_1 = require("./util");
  7. /**
  8. * Places the connection point at the intersection between the
  9. * link path end segment and the element's unrotated bbox.
  10. */
  11. const rect = function (line, view, magnet, options, type) {
  12. const cell = view.cell;
  13. const angle = cell.isNode() ? cell.getAngle() : 0;
  14. if (angle === 0) {
  15. return x6_common_1.FunctionExt.call(bbox_1.bbox, this, line, view, magnet, options, type);
  16. }
  17. const bboxRaw = view.getUnrotatedBBoxOfElement(magnet);
  18. if (options.stroked) {
  19. bboxRaw.inflate((0, util_1.getStrokeWidth)(magnet) / 2);
  20. }
  21. const center = bboxRaw.getCenter();
  22. const lineRaw = line.clone().rotate(angle, center);
  23. const intersections = lineRaw.setLength(1e6).intersect(bboxRaw);
  24. const p = intersections && intersections.length
  25. ? lineRaw.start.closest(intersections).rotate(-angle, center)
  26. : line.end;
  27. return (0, util_1.offset)(p, line.start, options.offset);
  28. };
  29. exports.rect = rect;
  30. //# sourceMappingURL=rect.js.map