targetj 1.0.235 → 1.0.237

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.
@@ -44,7 +44,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
44
44
  reasyncStyle: [],
45
45
  reattach: [],
46
46
  relocation: [],
47
- invisibleDom: [],
47
+ deletedDom: [],
48
48
  noDom: [],
49
49
  updatingTModels: [],
50
50
  activeTModels: [],
@@ -52,6 +52,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
52
52
  activeTargets: []
53
53
  };
54
54
  this.visibleOidMap = {};
55
+ this.preservedDomMap = {};
55
56
  this.targetMethodMap = {};
56
57
  this.noDomMap = {};
57
58
  }
@@ -76,6 +77,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
76
77
  key: "clearAll",
77
78
  value: function clearAll() {
78
79
  this.visibleOidMap = {};
80
+ this.preservedDomMap = {};
79
81
  this.clearFrameLists();
80
82
  this.deleteDoms();
81
83
  }
@@ -84,6 +86,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
84
86
  value: function analyze() {
85
87
  var _this = this;
86
88
  var lastVisibleMap = _objectSpread({}, this.visibleOidMap);
89
+ var lastPreservedMap = _objectSpread({}, this.preservedDomMap);
87
90
  this.clearFrameLists();
88
91
  var activated = [];
89
92
  var _iterator = _createForOfIteratorHelper((0, _App.getLocationManager)().hasLocationList),
@@ -92,35 +95,40 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
92
95
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
93
96
  var tmodel = _step.value;
94
97
  lastVisibleMap[tmodel.oid] = undefined;
98
+ lastPreservedMap[tmodel.oid] = undefined;
95
99
  if (!tmodel.exists()) {
96
100
  if (tmodel.hasDom()) {
97
- this.addToInvisibleDom(tmodel);
101
+ this.addToDeletedDom(tmodel);
98
102
  }
99
103
  delete this.visibleOidMap[tmodel.oid];
104
+ delete this.preservedDomMap[tmodel.oid];
100
105
  continue;
101
106
  }
102
107
  var visible = tmodel.isVisible();
103
108
  if (visible && tmodel.isIncluded()) {
104
109
  this.visibleOidMap[tmodel.oid] = tmodel;
110
+ delete this.preservedDomMap[tmodel.oid];
105
111
  this.lists.visible.push(tmodel);
106
112
  } else {
107
113
  delete this.visibleOidMap[tmodel.oid];
108
114
  }
109
- var keepDom = this.shouldPreserveDom(tmodel);
110
- if (keepDom) {
111
- this.visibleOidMap[tmodel.oid] = tmodel;
115
+ var preserveDom = this.shouldPreserveDom(tmodel);
116
+ if (!visible && preserveDom && tmodel.hasDom()) {
117
+ this.preservedDomMap[tmodel.oid] = tmodel;
118
+ } else {
119
+ delete this.preservedDomMap[tmodel.oid];
112
120
  }
113
121
  if (tmodel.hasDom()) {
114
- if (!tmodel.canHaveDom() || !tmodel.isIncluded() || tmodel.canDeleteDom() && !visible && !keepDom) {
115
- this.addToInvisibleDom(tmodel);
122
+ if (!tmodel.canHaveDom() || !tmodel.isIncluded() || tmodel.canDeleteDom() && !visible && !preserveDom) {
123
+ this.addToDeletedDom(tmodel);
116
124
  tmodel.getChildren().forEach(function (tmodel) {
117
125
  if (!tmodel.managesOwnScroll()) {
118
- _this.addToRecursiveInvisibleDom(tmodel);
126
+ _this.addToRecursiveDeletedDom(tmodel);
119
127
  }
120
128
  });
121
129
  }
122
130
  }
123
- if (visible || tmodel.isActivated() || keepDom) {
131
+ if (visible || tmodel.isActivated()) {
124
132
  var _state$updatingTarget, _state$activeTargetLi;
125
133
  var state = tmodel.state();
126
134
  if (((_state$updatingTarget = state.updatingTargetList) === null || _state$updatingTarget === void 0 ? void 0 : _state$updatingTarget.length) > 0 || tmodel.hasAnimatingTargets()) {
@@ -132,7 +140,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
132
140
  this.lists.activeTargets = [].concat(_toConsumableArray(this.lists.activeTargets), _toConsumableArray(state.activeTargetList));
133
141
  }
134
142
  }
135
- if (visible || tmodel.isActivated() || keepDom) {
143
+ if (visible || tmodel.isActivated()) {
136
144
  if (this.needsRerender(tmodel)) {
137
145
  this.lists.rerender.push(tmodel);
138
146
  }
@@ -157,7 +165,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
157
165
  activated.push(tmodel);
158
166
  }
159
167
  }
160
- if (visible || tmodel.requiresDom() || keepDom) {
168
+ if (visible || tmodel.requiresDom()) {
161
169
  if (tmodel.canHaveDom() && !tmodel.hasDom() && tmodel.isIncluded() && !this.noDomMap[tmodel.oid]) {
162
170
  var _tmodel$getDomHolder, _tmodel$getDomParent;
163
171
  if ((_tmodel$getDomHolder = tmodel.getDomHolder()) !== null && _tmodel$getDomHolder !== void 0 && _tmodel$getDomHolder.exists() || this.noDomMap[(_tmodel$getDomParent = tmodel.getDomParent()) === null || _tmodel$getDomParent === void 0 ? void 0 : _tmodel$getDomParent.oid]) {
@@ -177,27 +185,27 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
177
185
  activated.forEach(function (t) {
178
186
  return t.deactivate();
179
187
  });
180
- Object.values(lastVisibleMap).filter(function (v) {
188
+ Object.values(_objectSpread(_objectSpread({}, lastVisibleMap), lastPreservedMap)).filter(function (v) {
181
189
  return v !== undefined;
182
190
  }).forEach(function (tmodel) {
183
191
  if (tmodel.hasDom()) {
184
192
  if (!tmodel.exists() || !tmodel.isIncluded()) {
185
- _this.addToInvisibleDom(tmodel);
193
+ _this.addToDeletedDom(tmodel);
186
194
  }
187
195
  }
188
196
  });
189
- return this.lists.noDom.length > 0 ? 0 : this.lists.reattach.length > 0 ? 1 : this.lists.relocation.length > 0 ? 2 : this.lists.rerender.length > 0 ? 3 : this.lists.reasyncStyle.length > 0 ? 4 : this.lists.invisibleDom.length > 0 ? 5 : this.lists.restyle.length > 0 ? 10 : -1;
197
+ return this.lists.noDom.length > 0 ? 0 : this.lists.reattach.length > 0 ? 1 : this.lists.relocation.length > 0 ? 2 : this.lists.rerender.length > 0 ? 3 : this.lists.reasyncStyle.length > 0 ? 4 : this.lists.deletedDom.length > 0 ? 5 : this.lists.restyle.length > 0 ? 10 : -1;
190
198
  }
191
199
  }, {
192
200
  key: "shouldPreserveDom",
193
201
  value: function shouldPreserveDom(tmodel) {
194
- if (!tmodel.isVisible() && _TUtil.TUtil.isDefined(tmodel.targets.isVisible)) {
202
+ if (!tmodel.isIncluded()) {
195
203
  return false;
196
204
  }
197
- var parent = tmodel.parent;
198
- if (!tmodel.isIncluded()) {
205
+ if (!tmodel.isVisible() && _TUtil.TUtil.isDefined(tmodel.targets.isVisible)) {
199
206
  return false;
200
207
  }
208
+ var parent = tmodel.parent;
201
209
  while (parent && parent !== (0, _App.tRoot)()) {
202
210
  if (_TUtil.TUtil.isDefined(parent.targets.canDeleteDom)) {
203
211
  return parent.val('canDeleteDom') === false;
@@ -225,27 +233,29 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
225
233
  return true;
226
234
  }
227
235
  }, {
228
- key: "addToRecursiveInvisibleDom",
229
- value: function addToRecursiveInvisibleDom(tmodel) {
236
+ key: "addToRecursiveDeletedDom",
237
+ value: function addToRecursiveDeletedDom(tmodel) {
230
238
  var _this2 = this;
231
239
  delete this.visibleOidMap[tmodel.oid];
232
- if (!this.lists.invisibleDom.includes(tmodel)) {
240
+ delete this.preservedDomMap[tmodel.oid];
241
+ if (!this.lists.deletedDom.includes(tmodel)) {
233
242
  if (tmodel.hasDom()) {
234
- this.lists.invisibleDom.push(tmodel);
243
+ this.lists.deletedDom.push(tmodel);
235
244
  }
236
245
  tmodel.getChildren().forEach(function (tmodel) {
237
246
  if (!tmodel.managesOwnScroll()) {
238
- _this2.addToRecursiveInvisibleDom(tmodel);
247
+ _this2.addToRecursiveDeletedDom(tmodel);
239
248
  }
240
249
  });
241
250
  }
242
251
  }
243
252
  }, {
244
- key: "addToInvisibleDom",
245
- value: function addToInvisibleDom(tmodel) {
253
+ key: "addToDeletedDom",
254
+ value: function addToDeletedDom(tmodel) {
246
255
  delete this.visibleOidMap[tmodel.oid];
247
- if (!this.lists.invisibleDom.includes(tmodel)) {
248
- this.lists.invisibleDom.push(tmodel);
256
+ delete this.preservedDomMap[tmodel.oid];
257
+ if (!this.lists.deletedDom.includes(tmodel)) {
258
+ this.lists.deletedDom.push(tmodel);
249
259
  }
250
260
  }
251
261
  }, {
@@ -253,6 +263,11 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
253
263
  value: function getVisibles() {
254
264
  return Object.values(this.visibleOidMap);
255
265
  }
266
+ }, {
267
+ key: "getAvailableDoms",
268
+ value: function getAvailableDoms() {
269
+ return Object.values(_objectSpread(_objectSpread({}, this.preservedDomMap), this.visibleOidMap));
270
+ }
256
271
  }, {
257
272
  key: "needsRelocation",
258
273
  value: function needsRelocation(tmodel) {
@@ -384,7 +399,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
384
399
  }, {
385
400
  key: "deleteDoms",
386
401
  value: function deleteDoms() {
387
- var _iterator5 = _createForOfIteratorHelper(this.lists.invisibleDom),
402
+ var _iterator5 = _createForOfIteratorHelper(this.lists.deletedDom),
388
403
  _step5;
389
404
  try {
390
405
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
@@ -399,7 +414,7 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
399
414
  } finally {
400
415
  _iterator5.f();
401
416
  }
402
- this.lists.invisibleDom.length = 0;
417
+ this.lists.deletedDom.length = 0;
403
418
  }
404
419
  }, {
405
420
  key: "deleteDom",
package/build/TUtil.js CHANGED
@@ -7,6 +7,7 @@ exports.TUtil = void 0;
7
7
  var _App = require("./App.js");
8
8
  var _TargetUtil = require("./TargetUtil.js");
9
9
  var _TargetData = require("./TargetData.js");
10
+ var _TModel = require("./TModel.js");
10
11
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
12
  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); }
12
13
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
@@ -22,134 +23,13 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
22
23
  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); }
23
24
  /**
24
25
  *
25
- * It provide a variety of helping functions that are used by the framework.
26
+ * It provides a variety of helping functions that are used by the framework.
26
27
  */
27
28
  var TUtil = exports.TUtil = /*#__PURE__*/function () {
28
29
  function TUtil() {
29
30
  _classCallCheck(this, TUtil);
30
31
  }
31
32
  return _createClass(TUtil, null, [{
32
- key: "calcVisibility",
33
- value: function calcVisibility(child) {
34
- var _parent$targets$onVis;
35
- var parent = child.getRealParent();
36
- 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;
37
- if (!onVisibleChildrenChange && child.isVisible() && (child.isTargetUpdating(child.allTargetMap['x']) || child.isTargetUpdating(child.allTargetMap['y']))) {
38
- return true;
39
- }
40
- var domParent = child.getDomParent();
41
- var scale = (domParent.getMeasuringScale() || 1) * child.getMeasuringScale();
42
- var x = child.absX;
43
- var y = child.absY;
44
- var width = TUtil.isDefined(child.getWidth()) ? scale * child.getWidth() : 0;
45
- var height = TUtil.isDefined(child.getHeight()) ? scale * child.getHeight() : 0;
46
- var visibilityMargin = 20;
47
- if (!child.visibilityStatus) {
48
- child.visibilityStatus = {};
49
- }
50
- var status = child.visibilityStatus;
51
- var clip = this.getVisibilityClipRect(child.getParent());
52
- if (clip) {
53
- status.right = x - visibilityMargin <= clip.r;
54
- status.left = x + width + visibilityMargin >= clip.x;
55
- status.bottom = y - child.getTopMargin() - visibilityMargin <= clip.b;
56
- status.top = y + height + visibilityMargin >= clip.y;
57
- status.clipX = clip.x;
58
- status.clipY = clip.y;
59
- status.clipR = clip.r;
60
- status.clipB = clip.b;
61
- status.parent = clip.source;
62
- status.isVisible = status.left && status.right && status.top && status.bottom;
63
- } else {
64
- status.right = true;
65
- status.left = true;
66
- status.bottom = true;
67
- status.top = true;
68
- status.clipX = undefined;
69
- status.clipY = undefined;
70
- status.clipR = undefined;
71
- status.clipB = undefined;
72
- status.parent = "none";
73
- status.isVisible = true;
74
- }
75
- status.x = x;
76
- status.y = y;
77
- status.width = width;
78
- status.height = height;
79
- child.actualValues.isVisible = status.isVisible;
80
- return status.isVisible;
81
- }
82
- }, {
83
- key: "getVisibilityClipRect",
84
- value: function getVisibilityClipRect(container) {
85
- var rect = TUtil.getScreenViewportRect();
86
- while (container && container !== (0, _App.tRoot)()) {
87
- if (this.shouldClipByAncestor(container)) {
88
- var ancestorRect = this.getAncestorViewportRect(container);
89
- rect = rect && !container.allTargetMap['onWindowScroll'] ? this.intersectVisibilityRects(rect, ancestorRect) : ancestorRect;
90
- if (rect.r <= rect.x || rect.b <= rect.y) {
91
- break;
92
- }
93
- }
94
- container = container.getRealParent();
95
- }
96
- return rect;
97
- }
98
- }, {
99
- key: "getScreenViewportRect",
100
- value: function getScreenViewportRect() {
101
- return {
102
- x: 0,
103
- y: 0,
104
- r: (0, _App.getScreenWidth)(),
105
- b: (0, _App.getScreenHeight)(),
106
- source: "screen"
107
- };
108
- }
109
- }, {
110
- key: "shouldClipByAncestor",
111
- value: function shouldClipByAncestor(ancestor) {
112
- return ancestor.managesOwnScroll();
113
- }
114
- }, {
115
- key: "getAncestorViewportRect",
116
- value: function getAncestorViewportRect(ancestor) {
117
- var _ancestor$$dom, _ancestor$$dom2;
118
- var domScrollLeft = ((_ancestor$$dom = ancestor.$dom) === null || _ancestor$$dom === void 0 ? void 0 : _ancestor$$dom.getScrollLeft()) || 0;
119
- var domScrollTop = ((_ancestor$$dom2 = ancestor.$dom) === null || _ancestor$$dom2 === void 0 ? void 0 : _ancestor$$dom2.getScrollTop()) || 0;
120
- return {
121
- x: ancestor.absX + domScrollLeft,
122
- y: ancestor.absY + domScrollTop,
123
- r: ancestor.absX + domScrollLeft + ancestor.getWidth(),
124
- b: ancestor.absY + domScrollTop + ancestor.getHeight(),
125
- source: ancestor
126
- };
127
- }
128
- }, {
129
- key: "intersectVisibilityRects",
130
- value: function intersectVisibilityRects(a, b) {
131
- return {
132
- x: Math.max(a.x, b.x),
133
- y: Math.max(a.y, b.y),
134
- r: Math.min(a.r, b.r),
135
- b: Math.min(a.b, b.b),
136
- source: b.source
137
- };
138
- }
139
- }, {
140
- key: "updateClipRect",
141
- value: function updateClipRect(tmodel) {
142
- var parent = tmodel.getParent();
143
- var inheritedClip = (parent === null || parent === void 0 ? void 0 : parent.visibilityClipRect) || null;
144
- if (this.shouldClipByAncestor(tmodel)) {
145
- var localRect = this.getLocalViewportRect(tmodel);
146
- tmodel.visibilityClipRect = inheritedClip ? this.intersectVisibilityRects(inheritedClip, localRect) : localRect;
147
- } else {
148
- tmodel.visibilityClipRect = inheritedClip;
149
- }
150
- return tmodel.visibilityClipRect;
151
- }
152
- }, {
153
33
  key: "contains",
154
34
  value: function contains(container, tmodel) {
155
35
  var _tmodel$getDomParent;
@@ -364,6 +244,12 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
364
244
  tmodel.setScheduleTimeStamp(key, now);
365
245
  return 0;
366
246
  }
247
+ var remaining = tmodel.getScheduleRemainingTime(key);
248
+ if (TUtil.isDefined(remaining)) {
249
+ tmodel.setScheduleTimeStamp(key, now - Math.max(interval - remaining, 0));
250
+ tmodel.resetScheduleRemainingTime(key);
251
+ return remaining;
252
+ }
367
253
  var lastScheduledTime = tmodel.getScheduleTimeStamp(key);
368
254
  if (TUtil.isDefined(lastScheduledTime)) {
369
255
  var elapsed = now - lastScheduledTime;
@@ -372,6 +258,32 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
372
258
  tmodel.setScheduleTimeStamp(key, now);
373
259
  return interval;
374
260
  }
261
+ }, {
262
+ key: "pauseSchedule",
263
+ value: function pauseSchedule(tmodel, key) {
264
+ var interval = tmodel.getTargetInterval(key);
265
+ var lastScheduledTime = tmodel.getScheduleTimeStamp(key);
266
+ if (interval <= 0 || !TUtil.isDefined(lastScheduledTime)) {
267
+ return;
268
+ }
269
+ var now = TUtil.now();
270
+ var elapsed = now - lastScheduledTime;
271
+ var remaining = Math.max(interval - elapsed, 0);
272
+ tmodel.setScheduleRemainingTime(key, remaining);
273
+ tmodel.resetScheduleTimeStamp(key);
274
+ }
275
+ }, {
276
+ key: "resumeSchedule",
277
+ value: function resumeSchedule(tmodel, key) {
278
+ var remaining = tmodel.getScheduleRemainingTime(key);
279
+ if (!TUtil.isDefined(remaining)) {
280
+ return;
281
+ }
282
+ var now = TUtil.now();
283
+ var interval = tmodel.getTargetInterval(key);
284
+ tmodel.setScheduleTimeStamp(key, now - Math.max(interval - remaining, 0));
285
+ tmodel.resetScheduleRemainingTime(key);
286
+ }
375
287
  }, {
376
288
  key: "runTargetValue",
377
289
  value: function runTargetValue(tmodel, target, key, cycle, lastValue) {
@@ -405,5 +317,56 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
405
317
  tmodel1.processNewTarget(key, keyIndex);
406
318
  });
407
319
  }
320
+ }, {
321
+ key: "cloneTargetDefinition",
322
+ value: function cloneTargetDefinition(value) {
323
+ var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
324
+ if (!TUtil.isDefined(value) || _typeof(value) !== 'object') {
325
+ return value;
326
+ }
327
+
328
+ // Keep functions shared. They are behavior, not per-instance state.
329
+ if (typeof value === 'function') {
330
+ return value;
331
+ }
332
+
333
+ // Avoid cloning DOM wrappers, real DOM nodes, TModels, etc.
334
+ if (value instanceof _TModel.TModel || value instanceof Element || value instanceof Node || value instanceof Date || value instanceof RegExp) {
335
+ return value;
336
+ }
337
+ if (seen.has(value)) {
338
+ return seen.get(value);
339
+ }
340
+ if (Array.isArray(value)) {
341
+ var arr = [];
342
+ seen.set(value, arr);
343
+ var _iterator2 = _createForOfIteratorHelper(value),
344
+ _step2;
345
+ try {
346
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
347
+ var item = _step2.value;
348
+ arr.push(TUtil.cloneTargetDefinition(item, seen));
349
+ }
350
+ } catch (err) {
351
+ _iterator2.e(err);
352
+ } finally {
353
+ _iterator2.f();
354
+ }
355
+ return arr;
356
+ }
357
+ var proto = Object.getPrototypeOf(value);
358
+
359
+ // Only deep-clone plain objects.
360
+ if (proto !== Object.prototype && proto !== null) {
361
+ return value;
362
+ }
363
+ var cloned = {};
364
+ seen.set(value, cloned);
365
+ for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
366
+ var key = _Object$keys[_i];
367
+ cloned[key] = TUtil.cloneTargetDefinition(value[key], seen);
368
+ }
369
+ return cloned;
370
+ }
408
371
  }]);
409
372
  }();
@@ -311,7 +311,7 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
311
311
  tmodel.setTargetMethodName(key, "onComplete");
312
312
  }
313
313
  var fetchAction = target === null || target === void 0 ? void 0 : target.fetchAction;
314
- if (fetchAction && (0, _App.getLoader)().isLoadingComplete(tmodel, key)) {
314
+ if (fetchAction && (0, _App.getLoader)().isLoadingSuccessful(tmodel, key)) {
315
315
  var index = tmodel.fetchActionTargetList.indexOf(key);
316
316
  if (index >= 0) {
317
317
  tmodel.fetchActionTargetList.splice(index, 1);
@@ -439,7 +439,7 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
439
439
  }
440
440
  if (tmodel.isTargetTreeComplete(targetName) !== true) {
441
441
  //const activeChildrenList = [ ...TargetUtil.getActiveChildren(tmodel, tmodel.targets[targetName].completionScope).values() ];
442
- //return tmodel.oid + "." + targetName + " ==> " + tmodel.getTargetStatus(targetName) + ", " + tmodel.isTargetTreeComplete(targetName) + ":: " + activeChildrenList.map(t => t.oid + ':' + t.hasAnyUpdates()) + ", " + [ ...TargetUtil.getUpdatingChildren(tmodel, targetName).keys() ];
442
+ //return tmodel.oid + "." + targetName + " ==> " + tmodel.getTargetStatus(targetName) + ", " + tmodel.isTargetTreeComplete(targetName) + ":: " + activeChildrenList.map(t => t.oid + ':' + t.hasAnyUpdates()) + ", " + [ ...TargetUtil.getUpdatingChildren(tmodel, targetName, tmodel.targets[targetName].completionScope).keys() ];
443
443
  return false;
444
444
  }
445
445
  }
@@ -579,6 +579,9 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
579
579
  }, {
580
580
  key: "shouldIgnoreChildForCompletion",
581
581
  value: function shouldIgnoreChildForCompletion(child, completionScope) {
582
+ if (!child.exists()) {
583
+ return true;
584
+ }
582
585
  if (completionScope === "none") {
583
586
  return true;
584
587
  }
@@ -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
  });