targetj 1.0.241 → 1.0.243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,56 +31,53 @@ var VisibilityUtil = /*#__PURE__*/function () {
31
31
  var width = TUtil.isDefined(child.getWidth()) ? scale * child.getWidth() : 0;
32
32
  var height = TUtil.isDefined(child.getHeight()) ? scale * child.getHeight() : 0;
33
33
  var visibilityMargin = 20;
34
- if (!child.visibilityStatus) {
35
- child.visibilityStatus = {};
36
- }
37
- var status = child.visibilityStatus;
38
- var clip = VisibilityUtil.getVisibilityClipRect(child.getParent());
39
- if (clip) {
40
- status.right = x - visibilityMargin <= clip.r;
41
- status.left = x + width + visibilityMargin >= clip.x;
42
- status.bottom = y - child.getTopMargin() - visibilityMargin <= clip.b;
43
- status.top = y + height + child.getBottomMargin() + visibilityMargin >= clip.y;
44
- status.clipX = clip.x;
45
- status.clipY = clip.y;
46
- status.clipR = clip.r;
47
- status.clipB = clip.b;
48
- status.parent = clip.source;
49
- status.isVisible = status.left && status.right && status.top && status.bottom;
50
- } else {
51
- status.right = true;
52
- status.left = true;
53
- status.bottom = true;
54
- status.top = true;
55
- status.clipX = undefined;
56
- status.clipY = undefined;
57
- status.clipR = undefined;
58
- status.clipB = undefined;
59
- status.parent = "none";
60
- status.isVisible = true;
61
- }
34
+ var rect = {
35
+ x: x - visibilityMargin,
36
+ y: y - visibilityMargin,
37
+ r: x + width + visibilityMargin,
38
+ b: y + height + visibilityMargin
39
+ };
40
+ var status = VisibilityUtil.checkVisibility(child, rect);
62
41
  status.x = x;
63
42
  status.y = y;
64
43
  status.width = width;
65
44
  status.height = height;
45
+ child.visibilityStatus = status;
66
46
  child.actualValues.isVisible = status.isVisible;
67
47
  return status.isVisible;
68
48
  }
69
49
  }, {
70
- key: "getVisibilityClipRect",
71
- value: function getVisibilityClipRect(container) {
72
- var rect = VisibilityUtil.getScreenViewportRect();
73
- while (container && container !== tRoot()) {
74
- if (VisibilityUtil.shouldClipByAncestor(container)) {
75
- var ancestorRect = VisibilityUtil.getAncestorViewportRect(container);
76
- rect = rect && !container.allTargetMap['onWindowScroll'] ? VisibilityUtil.intersectVisibilityRects(rect, ancestorRect) : ancestorRect;
77
- if (rect.r <= rect.x || rect.b <= rect.y) {
78
- break;
50
+ key: "checkVisibility",
51
+ value: function checkVisibility(tmodel, rect) {
52
+ while (tmodel) {
53
+ var parent = tmodel.getRealParent();
54
+ if (!parent || parent === tRoot()) {
55
+ break;
56
+ }
57
+ if (VisibilityUtil.shouldClipByAncestor(parent)) {
58
+ var _clip = VisibilityUtil.getParentClip(parent);
59
+ var _isVisible = VisibilityUtil.rectsOverlap(rect, _clip);
60
+ if (!_isVisible) {
61
+ return {
62
+ clip: _clip,
63
+ isVisible: false
64
+ };
79
65
  }
66
+ rect = VisibilityUtil.intersectRects(parent, rect, _clip);
80
67
  }
81
- container = container.getRealParent();
68
+ tmodel = parent;
69
+ }
70
+ var clip = VisibilityUtil.getScreenViewportRect();
71
+ var isVisible = VisibilityUtil.rectsOverlap(rect, clip);
72
+ if (!isVisible) {
73
+ return {
74
+ clip: clip,
75
+ isVisible: false
76
+ };
82
77
  }
83
- return rect;
78
+ return {
79
+ isVisible: true
80
+ };
84
81
  }
85
82
  }, {
86
83
  key: "getScreenViewportRect",
@@ -96,30 +93,41 @@ var VisibilityUtil = /*#__PURE__*/function () {
96
93
  }, {
97
94
  key: "shouldClipByAncestor",
98
95
  value: function shouldClipByAncestor(ancestor) {
99
- return ancestor.managesOwnScroll();
96
+ var overflow = ancestor.val("overflow");
97
+ return ancestor.managesOwnScroll() || overflow === "hidden" || overflow === "auto" || overflow === "scroll" || overflow === "clip";
100
98
  }
101
99
  }, {
102
- key: "getAncestorViewportRect",
103
- value: function getAncestorViewportRect(ancestor) {
104
- var _ancestor$$dom, _ancestor$$dom2;
105
- var domScrollLeft = ((_ancestor$$dom = ancestor.$dom) === null || _ancestor$$dom === void 0 ? void 0 : _ancestor$$dom.getScrollLeft()) || 0;
106
- var domScrollTop = ((_ancestor$$dom2 = ancestor.$dom) === null || _ancestor$$dom2 === void 0 ? void 0 : _ancestor$$dom2.getScrollTop()) || 0;
100
+ key: "getParentClip",
101
+ value: function getParentClip(parent) {
102
+ var _parent$$dom, _parent$$dom2;
103
+ var domScrollLeft = ((_parent$$dom = parent.$dom) === null || _parent$$dom === void 0 ? void 0 : _parent$$dom.getScrollLeft()) || 0;
104
+ var domScrollTop = ((_parent$$dom2 = parent.$dom) === null || _parent$$dom2 === void 0 ? void 0 : _parent$$dom2.getScrollTop()) || 0;
105
+ var height = parent.getHeight();
106
+ var width = parent.getWidth();
107
107
  return {
108
- x: ancestor.absX + domScrollLeft,
109
- y: ancestor.absY + domScrollTop,
110
- r: ancestor.absX + domScrollLeft + ancestor.getWidth(),
111
- b: ancestor.absY + domScrollTop + ancestor.getHeight(),
112
- source: ancestor
108
+ x: parent.absX + domScrollLeft,
109
+ y: parent.absY + domScrollTop,
110
+ r: parent.absX + width + domScrollLeft,
111
+ b: parent.absY + height + domScrollTop,
112
+ source: parent
113
113
  };
114
114
  }
115
115
  }, {
116
- key: "intersectVisibilityRects",
117
- value: function intersectVisibilityRects(a, b) {
116
+ key: "rectsOverlap",
117
+ value: function rectsOverlap(a, b) {
118
+ return a.x <= b.r && a.r >= b.x && a.y <= b.b && a.b >= b.y;
119
+ }
120
+ }, {
121
+ key: "intersectRects",
122
+ value: function intersectRects(parent, a, b) {
123
+ var _parent$$dom3, _parent$$dom4;
124
+ var domScrollLeft = ((_parent$$dom3 = parent.$dom) === null || _parent$$dom3 === void 0 ? void 0 : _parent$$dom3.getScrollLeft()) || 0;
125
+ var domScrollTop = ((_parent$$dom4 = parent.$dom) === null || _parent$$dom4 === void 0 ? void 0 : _parent$$dom4.getScrollTop()) || 0;
118
126
  return {
119
- x: Math.max(a.x, b.x),
120
- y: Math.max(a.y, b.y),
121
- r: Math.min(a.r, b.r),
122
- b: Math.min(a.b, b.b),
127
+ x: Math.max(a.x - domScrollLeft, b.x - domScrollLeft),
128
+ y: Math.max(a.y - domScrollTop, b.y - domScrollTop),
129
+ r: Math.min(a.r - domScrollLeft, b.r - domScrollLeft),
130
+ b: Math.min(a.b - domScrollTop, b.b - domScrollTop),
123
131
  source: b.source
124
132
  };
125
133
  }