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.
- package/README.md +109 -69
- package/build/AnimationManager.js +1 -1
- package/build/BaseModel.js +1 -3
- package/build/Bracket.js +0 -10
- package/build/EventListener.js +4 -9
- package/build/RunScheduler.js +26 -23
- package/build/TModel.js +107 -43
- package/build/TModelManager.js +44 -9
- package/build/TModelUtil.js +75 -3
- package/build/TargetData.js +5 -5
- package/build/TargetExecutor.js +1 -1
- package/build/TargetManager.js +4 -0
- package/build/TargetUtil.js +3 -2
- package/build/Viewport.js +19 -13
- package/build/VisibilityUtil.js +64 -56
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/build/VisibilityUtil.js
CHANGED
|
@@ -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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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: "
|
|
71
|
-
value: function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
96
|
+
var overflow = ancestor.val("overflow");
|
|
97
|
+
return ancestor.managesOwnScroll() || overflow === "hidden" || overflow === "auto" || overflow === "scroll" || overflow === "clip";
|
|
100
98
|
}
|
|
101
99
|
}, {
|
|
102
|
-
key: "
|
|
103
|
-
value: function
|
|
104
|
-
var
|
|
105
|
-
var domScrollLeft = ((
|
|
106
|
-
var domScrollTop = ((
|
|
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:
|
|
109
|
-
y:
|
|
110
|
-
r:
|
|
111
|
-
b:
|
|
112
|
-
source:
|
|
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: "
|
|
117
|
-
value: function
|
|
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
|
}
|