util.js 907 B

123456789101112131415161718192021222324252627282930
  1. export function removeFromArray(arr, obj) {
  2. var index = arr.indexOf(obj);
  3. if (index !== -1) {
  4. arr.splice(index, 1);
  5. }
  6. }
  7. export var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
  8. export { isNil, isFunction, isString, isObject, isArray, mix, each, upperFirst } from '@antv/util';
  9. // 是否元素的父容器
  10. export function isParent(container, shape) {
  11. // 所有 shape 都是 canvas 的子元素
  12. if (container.isCanvas()) {
  13. return true;
  14. }
  15. var parent = shape.getParent();
  16. var isParent = false;
  17. while (parent) {
  18. if (parent === container) {
  19. isParent = true;
  20. break;
  21. }
  22. parent = parent.getParent();
  23. }
  24. return isParent;
  25. }
  26. export function isAllowCapture(element) {
  27. // @ts-ignore
  28. return element.cfg.visible && element.cfg.capture;
  29. }
  30. //# sourceMappingURL=util.js.map