bbox.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.bottomRight = exports.bottomLeft = exports.topRight = exports.topLeft = exports.right = exports.left = exports.bottom = exports.top = exports.center = void 0;
  4. const x6_common_1 = require("@antv/x6-common");
  5. exports.center = createBBoxAnchor('center');
  6. exports.top = createBBoxAnchor('topCenter');
  7. exports.bottom = createBBoxAnchor('bottomCenter');
  8. exports.left = createBBoxAnchor('leftMiddle');
  9. exports.right = createBBoxAnchor('rightMiddle');
  10. exports.topLeft = createBBoxAnchor('topLeft');
  11. exports.topRight = createBBoxAnchor('topRight');
  12. exports.bottomLeft = createBBoxAnchor('bottomLeft');
  13. exports.bottomRight = createBBoxAnchor('bottomRight');
  14. function createBBoxAnchor(method) {
  15. return function (view, magnet, ref, options = {}) {
  16. const bbox = options.rotate
  17. ? view.getUnrotatedBBoxOfElement(magnet)
  18. : view.getBBoxOfElement(magnet);
  19. const result = bbox[method];
  20. result.x += x6_common_1.NumberExt.normalizePercentage(options.dx, bbox.width);
  21. result.y += x6_common_1.NumberExt.normalizePercentage(options.dy, bbox.height);
  22. const cell = view.cell;
  23. return options.rotate
  24. ? result.rotate(-cell.getAngle(), cell.getBBox().getCenter())
  25. : result;
  26. };
  27. }
  28. //# sourceMappingURL=bbox.js.map