targetj 1.0.236 → 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.
package/Export.js CHANGED
@@ -35,6 +35,7 @@ import * as Easing from './build/Easing.js';
35
35
  import * as TargetExecutor from './build/TargetExecutor.js';
36
36
  import * as AnimationManager from './build/AnimationManager.js';
37
37
  import * as AnimationUtil from './build/AnimationUtil.js';
38
+ import * as VisibilityUtil from './build/VisibilityUtil.js';
38
39
 
39
40
  const TargetJS = {
40
41
  ...App,
@@ -53,7 +54,8 @@ const TargetJS = {
53
54
  ...Easing,
54
55
  ...TargetExecutor,
55
56
  ...AnimationManager,
56
- ...AnimationUtil
57
+ ...AnimationUtil,
58
+ ...VisibilityUtil
57
59
  };
58
60
 
59
61
  if (typeof window !== 'undefined') {
package/build/Bracket.js CHANGED
@@ -159,6 +159,10 @@ var Bracket = exports.Bracket = /*#__PURE__*/function (_TModel) {
159
159
  key: "shouldCalculateChildren",
160
160
  value: function shouldCalculateChildren() {
161
161
  var nowVisible = this.isVisible();
162
+ var hasEventDirty = this.hasEventDirty();
163
+ if (hasEventDirty) {
164
+ return true;
165
+ }
162
166
  if (this.currentBrakcetStatus >= 1 || this.isNowVisible || this.isNowInvisible) {
163
167
  this.currentBrakcetStatus = Math.max(0, this.currentBrakcetStatus - 1);
164
168
  return true;
@@ -174,7 +178,8 @@ var Bracket = exports.Bracket = /*#__PURE__*/function (_TModel) {
174
178
  }, {
175
179
  key: "getDirtyLayout",
176
180
  value: function getDirtyLayout() {
177
- return this.getRealParent().managesOwnScroll() ? this.getRealParent().backupDirtyLayout : this.dirtyLayout;
181
+ var parentDirty = this.getRealParent().managesOwnScroll() ? this.getRealParent().backupDirtyLayout : false;
182
+ return this.dirtyLayout || parentDirty || false;
178
183
  }
179
184
  }, {
180
185
  key: "validateVisibilityInParent",
@@ -486,6 +486,8 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
486
486
  var clickHandler = _SearchUtil.SearchUtil.findFirstClickHandler(tmodel);
487
487
  var canAcceptClick = !this.start0 || clickHandler === this.currentHandlers.click && (clickHandler !== this.currentHandlers.swipe || this.getSwipeDistance() < 5);
488
488
  if (clickHandler && canAcceptClick) {
489
+ clickHandler.markEventDirty();
490
+ clickHandler.markLayoutDirty('event');
489
491
  this.eventQueue.length = 0;
490
492
  this.eventQueue.push({
491
493
  eventName: eventName,
@@ -498,6 +500,7 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
498
500
  });
499
501
  }
500
502
  this.clearEnd();
503
+ this.clearStart();
501
504
  this.touchCount = 0;
502
505
  event.stopPropagation();
503
506
  break;
package/build/Moves.js CHANGED
@@ -131,25 +131,30 @@ var Moves = exports.Moves = /*#__PURE__*/function () {
131
131
  }, {
132
132
  key: "shake",
133
133
  value: function shake(tmodel) {
134
- var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : tmodel.getWidth();
135
- var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : tmodel.getHeight();
136
- var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
134
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
135
+ _ref3$xStart = _ref3.xStart,
136
+ xStart = _ref3$xStart === void 0 ? undefined : _ref3$xStart,
137
+ _ref3$width = _ref3.width,
138
+ width = _ref3$width === void 0 ? undefined : _ref3$width,
139
+ _ref3$height = _ref3.height,
140
+ height = _ref3$height === void 0 ? undefined : _ref3$height,
137
141
  _ref3$bFactor = _ref3.bFactor,
138
142
  bFactor = _ref3$bFactor === void 0 ? 0.6 : _ref3$bFactor,
139
143
  _ref3$cFactor = _ref3.cFactor,
140
144
  cFactor = _ref3$cFactor === void 0 ? 0.3 : _ref3$cFactor,
141
145
  _ref3$strength = _ref3.strength,
142
146
  strength = _ref3$strength === void 0 ? 20 : _ref3$strength;
143
- var xStart = (tmodel.getParentValue('width') - width) / 2;
147
+ var widthStart = _TUtil.TUtil.isDefined(width) ? width : tmodel.getWidth();
148
+ var heightStart = _TUtil.TUtil.isDefined(height) ? height : tmodel.getHeight();
149
+ var resolvedXStart = _TUtil.TUtil.isDefined(xStart) ? xStart : tmodel.getX();
144
150
  var yStart = tmodel.getY();
145
- var widthStart = width;
146
- var heightStart = height;
147
151
  var bounce = Moves.bounce(yStart - strength, yStart, {
148
- xStart: xStart,
152
+ xStart: resolvedXStart,
149
153
  widthStart: widthStart,
150
154
  heightStart: heightStart,
151
155
  bFactor: bFactor,
152
- cFactor: cFactor
156
+ cFactor: cFactor,
157
+ rIncrement: 0
153
158
  });
154
159
  return {
155
160
  x: bounce.x,
package/build/TModel.js CHANGED
@@ -8,6 +8,7 @@ var _BaseModel2 = require("./BaseModel.js");
8
8
  var _App = require("./App.js");
9
9
  var _Viewport = require("./Viewport.js");
10
10
  var _TUtil = require("./TUtil.js");
11
+ var _VisibilityUtil = require("./VisibilityUtil.js");
11
12
  var _TargetData = require("./TargetData.js");
12
13
  var _SearchUtil = require("./SearchUtil.js");
13
14
  var _TargetUtil = require("./TargetUtil.js");
@@ -166,10 +167,11 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
166
167
  var foundKey = Object.keys(this.actualValues).find(function (key) {
167
168
  return _this2.actualValues[key] === child;
168
169
  });
170
+ var childDefinition = _TUtil.TUtil.cloneTargetDefinition(child);
169
171
  if (foundKey) {
170
- child = new TModel(child.id || foundKey, child);
172
+ child = new TModel(childDefinition.id || foundKey, childDefinition);
171
173
  } else {
172
- child = new TModel("".concat(this.oid, "_"), child);
174
+ child = new TModel("".concat(this.oid, "_"), childDefinition);
173
175
  }
174
176
  }
175
177
  if (!child.toDiscard) {
@@ -347,6 +349,9 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
347
349
  key: "markEventDirty",
348
350
  value: function markEventDirty() {
349
351
  this.eventDirtyEpoch = (0, _App.getEvents)().eventEpoch;
352
+ if (this.bracket) {
353
+ this.bracket.markEventDirty();
354
+ }
350
355
  if (this.parent) {
351
356
  this.parent.markEventDirty();
352
357
  }
@@ -644,7 +649,7 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
644
649
  }, {
645
650
  key: "calcVisibility",
646
651
  value: function calcVisibility() {
647
- return _TUtil.TUtil.calcVisibility(this);
652
+ return _VisibilityUtil.VisibilityUtil.calcVisibility(this);
648
653
  }
649
654
  }, {
650
655
  key: "validateVisibilityInParent",
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;
@@ -437,5 +317,56 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
437
317
  tmodel1.processNewTarget(key, keyIndex);
438
318
  });
439
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
+ }
440
371
  }]);
441
372
  }();
@@ -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
  });