overflowHide.js 772 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.OverflowHide = void 0;
  4. const bounds_1 = require("../utils/bounds");
  5. const style_1 = require("../utils/style");
  6. /**
  7. * Hide the label when the label is overflowed from the element.
  8. */
  9. const OverflowHide = (options) => {
  10. return (labels, coordinate) => {
  11. labels.forEach((l) => {
  12. (0, style_1.show)(l);
  13. const bounds = l.attr('bounds');
  14. const b = l.getLocalBounds();
  15. const overflow = (0, bounds_1.isOverflow)((0, bounds_1.parseAABB)(b), bounds);
  16. if (overflow)
  17. (0, style_1.hide)(l);
  18. });
  19. return labels;
  20. };
  21. };
  22. exports.OverflowHide = OverflowHide;
  23. //# sourceMappingURL=overflowHide.js.map