targetj 1.0.236 → 1.0.238
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/Export.js +3 -1
- package/build/BaseModel.js +3 -3
- package/build/Bracket.js +6 -1
- package/build/EventListener.js +3 -0
- package/build/Moves.js +13 -8
- package/build/TModel.js +8 -3
- package/build/TUtil.js +53 -122
- package/build/TargetUtil.js +58 -76
- package/build/VisibilityUtil.js +132 -0
- package/build/index.js +11 -0
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VisibilityUtil = void 0;
|
|
7
|
+
var _App = require("./App.js");
|
|
8
|
+
var _TUtil = require("./TUtil.js");
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
12
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* It provides a variety of helping functions for calculating visibility
|
|
18
|
+
*/
|
|
19
|
+
var VisibilityUtil = exports.VisibilityUtil = /*#__PURE__*/function () {
|
|
20
|
+
function VisibilityUtil() {
|
|
21
|
+
_classCallCheck(this, VisibilityUtil);
|
|
22
|
+
}
|
|
23
|
+
return _createClass(VisibilityUtil, null, [{
|
|
24
|
+
key: "calcVisibility",
|
|
25
|
+
value: function calcVisibility(child) {
|
|
26
|
+
var _parent$targets$onVis;
|
|
27
|
+
var parent = child.getRealParent();
|
|
28
|
+
var onVisibleChildrenChange = (_parent$targets$onVis = parent === null || parent === void 0 ? void 0 : parent.targets['onVisibleChildrenChange']) !== null && _parent$targets$onVis !== void 0 ? _parent$targets$onVis : false;
|
|
29
|
+
if (!onVisibleChildrenChange && child.isVisible() && (child.isTargetUpdating(child.allTargetMap['x']) || child.isTargetUpdating(child.allTargetMap['y']))) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
var domParent = child.getDomParent();
|
|
33
|
+
var scale = (domParent.getMeasuringScale() || 1) * child.getMeasuringScale();
|
|
34
|
+
var x = child.absX;
|
|
35
|
+
var y = child.absY;
|
|
36
|
+
var width = _TUtil.TUtil.isDefined(child.getWidth()) ? scale * child.getWidth() : 0;
|
|
37
|
+
var height = _TUtil.TUtil.isDefined(child.getHeight()) ? scale * child.getHeight() : 0;
|
|
38
|
+
var visibilityMargin = 20;
|
|
39
|
+
if (!child.visibilityStatus) {
|
|
40
|
+
child.visibilityStatus = {};
|
|
41
|
+
}
|
|
42
|
+
var status = child.visibilityStatus;
|
|
43
|
+
var clip = VisibilityUtil.getVisibilityClipRect(child.getParent());
|
|
44
|
+
if (clip) {
|
|
45
|
+
status.right = x - visibilityMargin <= clip.r;
|
|
46
|
+
status.left = x + width + visibilityMargin >= clip.x;
|
|
47
|
+
status.bottom = y - child.getTopMargin() - visibilityMargin <= clip.b;
|
|
48
|
+
status.top = y + height + visibilityMargin >= clip.y;
|
|
49
|
+
status.clipX = clip.x;
|
|
50
|
+
status.clipY = clip.y;
|
|
51
|
+
status.clipR = clip.r;
|
|
52
|
+
status.clipB = clip.b;
|
|
53
|
+
status.parent = clip.source;
|
|
54
|
+
status.isVisible = status.left && status.right && status.top && status.bottom;
|
|
55
|
+
} else {
|
|
56
|
+
status.right = true;
|
|
57
|
+
status.left = true;
|
|
58
|
+
status.bottom = true;
|
|
59
|
+
status.top = true;
|
|
60
|
+
status.clipX = undefined;
|
|
61
|
+
status.clipY = undefined;
|
|
62
|
+
status.clipR = undefined;
|
|
63
|
+
status.clipB = undefined;
|
|
64
|
+
status.parent = "none";
|
|
65
|
+
status.isVisible = true;
|
|
66
|
+
}
|
|
67
|
+
status.x = x;
|
|
68
|
+
status.y = y;
|
|
69
|
+
status.width = width;
|
|
70
|
+
status.height = height;
|
|
71
|
+
child.actualValues.isVisible = status.isVisible;
|
|
72
|
+
return status.isVisible;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "getVisibilityClipRect",
|
|
76
|
+
value: function getVisibilityClipRect(container) {
|
|
77
|
+
var rect = VisibilityUtil.getScreenViewportRect();
|
|
78
|
+
while (container && container !== (0, _App.tRoot)()) {
|
|
79
|
+
if (VisibilityUtil.shouldClipByAncestor(container)) {
|
|
80
|
+
var ancestorRect = VisibilityUtil.getAncestorViewportRect(container);
|
|
81
|
+
rect = rect && !container.allTargetMap['onWindowScroll'] ? VisibilityUtil.intersectVisibilityRects(rect, ancestorRect) : ancestorRect;
|
|
82
|
+
if (rect.r <= rect.x || rect.b <= rect.y) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
container = container.getRealParent();
|
|
87
|
+
}
|
|
88
|
+
return rect;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "getScreenViewportRect",
|
|
92
|
+
value: function getScreenViewportRect() {
|
|
93
|
+
return {
|
|
94
|
+
x: 0,
|
|
95
|
+
y: 0,
|
|
96
|
+
r: (0, _App.getScreenWidth)(),
|
|
97
|
+
b: (0, _App.getScreenHeight)(),
|
|
98
|
+
source: "screen"
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "shouldClipByAncestor",
|
|
103
|
+
value: function shouldClipByAncestor(ancestor) {
|
|
104
|
+
return ancestor.managesOwnScroll();
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "getAncestorViewportRect",
|
|
108
|
+
value: function getAncestorViewportRect(ancestor) {
|
|
109
|
+
var _ancestor$$dom, _ancestor$$dom2;
|
|
110
|
+
var domScrollLeft = ((_ancestor$$dom = ancestor.$dom) === null || _ancestor$$dom === void 0 ? void 0 : _ancestor$$dom.getScrollLeft()) || 0;
|
|
111
|
+
var domScrollTop = ((_ancestor$$dom2 = ancestor.$dom) === null || _ancestor$$dom2 === void 0 ? void 0 : _ancestor$$dom2.getScrollTop()) || 0;
|
|
112
|
+
return {
|
|
113
|
+
x: ancestor.absX + domScrollLeft,
|
|
114
|
+
y: ancestor.absY + domScrollTop,
|
|
115
|
+
r: ancestor.absX + domScrollLeft + ancestor.getWidth(),
|
|
116
|
+
b: ancestor.absY + domScrollTop + ancestor.getHeight(),
|
|
117
|
+
source: ancestor
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "intersectVisibilityRects",
|
|
122
|
+
value: function intersectVisibilityRects(a, b) {
|
|
123
|
+
return {
|
|
124
|
+
x: Math.max(a.x, b.x),
|
|
125
|
+
y: Math.max(a.y, b.y),
|
|
126
|
+
r: Math.min(a.r, b.r),
|
|
127
|
+
b: Math.min(a.b, b.b),
|
|
128
|
+
source: b.source
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}]);
|
|
132
|
+
}();
|
package/build/index.js
CHANGED
|
@@ -200,4 +200,15 @@ Object.keys(_AnimationUtil).forEach(function (key) {
|
|
|
200
200
|
return _AnimationUtil[key];
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
|
+
});
|
|
204
|
+
var _VisibilityUtil = require("./VisibilityUtil.js");
|
|
205
|
+
Object.keys(_VisibilityUtil).forEach(function (key) {
|
|
206
|
+
if (key === "default" || key === "__esModule") return;
|
|
207
|
+
if (key in exports && exports[key] === _VisibilityUtil[key]) return;
|
|
208
|
+
Object.defineProperty(exports, key, {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function get() {
|
|
211
|
+
return _VisibilityUtil[key];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
203
214
|
});
|