util.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isAllowCapture = exports.isParent = exports.isBrowser = exports.removeFromArray = void 0;
  4. function removeFromArray(arr, obj) {
  5. var index = arr.indexOf(obj);
  6. if (index !== -1) {
  7. arr.splice(index, 1);
  8. }
  9. }
  10. exports.removeFromArray = removeFromArray;
  11. exports.isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
  12. var util_1 = require("@antv/util");
  13. Object.defineProperty(exports, "isNil", { enumerable: true, get: function () { return util_1.isNil; } });
  14. Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return util_1.isFunction; } });
  15. Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return util_1.isString; } });
  16. Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return util_1.isObject; } });
  17. Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return util_1.isArray; } });
  18. Object.defineProperty(exports, "mix", { enumerable: true, get: function () { return util_1.mix; } });
  19. Object.defineProperty(exports, "each", { enumerable: true, get: function () { return util_1.each; } });
  20. Object.defineProperty(exports, "upperFirst", { enumerable: true, get: function () { return util_1.upperFirst; } });
  21. // 是否元素的父容器
  22. function isParent(container, shape) {
  23. // 所有 shape 都是 canvas 的子元素
  24. if (container.isCanvas()) {
  25. return true;
  26. }
  27. var parent = shape.getParent();
  28. var isParent = false;
  29. while (parent) {
  30. if (parent === container) {
  31. isParent = true;
  32. break;
  33. }
  34. parent = parent.getParent();
  35. }
  36. return isParent;
  37. }
  38. exports.isParent = isParent;
  39. function isAllowCapture(element) {
  40. // @ts-ignore
  41. return element.cfg.visible && element.cfg.capture;
  42. }
  43. exports.isAllowCapture = isAllowCapture;
  44. //# sourceMappingURL=util.js.map