targetj 1.0.228 → 1.0.229

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/build/TUtil.js CHANGED
@@ -7,7 +7,6 @@ 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 _TargetParser = require("./TargetParser");
11
10
  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; } } }; }
12
11
  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); }
13
12
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
@@ -33,53 +32,112 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
33
32
  key: "calcVisibility",
34
33
  value: function calcVisibility(child) {
35
34
  var _parent$targets$onVis;
36
- // keep the "x updating" fast-path
37
-
38
35
  var parent = child.getRealParent();
39
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;
40
37
  if (!onVisibleChildrenChange && child.isVisible() && (child.isTargetUpdating(child.allTargetMap['x']) || child.isTargetUpdating(child.allTargetMap['y']))) {
41
38
  return true;
42
39
  }
43
- var x = child.absX;
44
- var y = child.absY;
45
40
  var domParent = child.getDomParent();
46
41
  var scale = (domParent.getMeasuringScale() || 1) * child.getMeasuringScale();
47
- var maxWidth = TUtil.isDefined(child.getWidth()) ? scale * child.getWidth() : 0;
48
- var maxHeight = TUtil.isDefined(child.getHeight()) ? scale * child.getHeight() : 0;
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;
49
47
  if (!child.visibilityStatus) {
50
48
  child.visibilityStatus = {};
51
49
  }
52
50
  var status = child.visibilityStatus;
53
- var validateInParent = child.validateVisibilityInParent() && parent !== (0, _App.tRoot)();
54
- var parentX = validateInParent ? Math.max(domParent.absX, parent.absX) : 0;
55
- var parentY = validateInParent ? Math.max(domParent.absY, parent.absY) : 0;
56
- var parentW = validateInParent ? Math.min(domParent.getWidth(), parent.getWidth()) : (0, _App.getScreenWidth)();
57
- var parentH = validateInParent ? Math.min(domParent.getHeight(), parent.getHeight()) : (0, _App.getScreenHeight)();
58
- var screenX = 0;
59
- var screenY = 0;
60
- var screenW = (0, _App.getScreenWidth)();
61
- var screenH = (0, _App.getScreenHeight)();
62
- var clipX = Math.max(parentX, screenX);
63
- var clipY = Math.max(parentY, screenY);
64
- var clipR = Math.min(parentX + parentW, screenX + screenW);
65
- var clipB = Math.min(parentY + parentH, screenY + screenH);
66
- status.right = x <= clipR;
67
- status.left = x + maxWidth >= clipX;
68
- status.bottom = y - child.getTopMargin() <= clipB;
69
- status.top = y + maxHeight >= clipY;
70
- status.clipX = clipX;
71
- status.clipY = clipY;
72
- status.clipR = clipR;
73
- status.clipB = clipB;
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
+ }
74
75
  status.x = x;
75
76
  status.y = y;
76
- status.width = maxWidth;
77
- status.height = maxHeight;
78
- status.parent = validateInParent ? parent : "screen";
79
- status.isVisible = status.left && status.right && status.top && status.bottom;
77
+ status.width = width;
78
+ status.height = height;
80
79
  child.actualValues.isVisible = status.isVisible;
81
80
  return status.isVisible;
82
81
  }
82
+ }, {
83
+ key: "getVisibilityClipRect",
84
+ value: function getVisibilityClipRect(container) {
85
+ var rect = null;
86
+ while (container && container !== (0, _App.tRoot)()) {
87
+ if (this.shouldClipByAncestor(container)) {
88
+ var ancestorRect = this.getAncestorViewportRect(container);
89
+ rect = rect ? this.intersectVisibilityRects(rect, ancestorRect) : ancestorRect;
90
+ if (rect.r <= rect.x || rect.b <= rect.y) {
91
+ break;
92
+ }
93
+ }
94
+ container = container.getParent();
95
+ }
96
+ return rect;
97
+ }
98
+ }, {
99
+ key: "shouldClipByAncestor",
100
+ value: function shouldClipByAncestor(ancestor) {
101
+ return ancestor.managesOwnScroll();
102
+ }
103
+ }, {
104
+ key: "getAncestorViewportRect",
105
+ value: function getAncestorViewportRect(ancestor) {
106
+ var _ancestor$$dom, _ancestor$$dom2;
107
+ var domScrollLeft = ((_ancestor$$dom = ancestor.$dom) === null || _ancestor$$dom === void 0 ? void 0 : _ancestor$$dom.getScrollLeft()) || 0;
108
+ var domScrollTop = ((_ancestor$$dom2 = ancestor.$dom) === null || _ancestor$$dom2 === void 0 ? void 0 : _ancestor$$dom2.getScrollTop()) || 0;
109
+ return {
110
+ x: ancestor.absX + domScrollLeft,
111
+ y: ancestor.absY + domScrollTop,
112
+ r: ancestor.absX + domScrollLeft + ancestor.getWidth(),
113
+ b: ancestor.absY + domScrollTop + ancestor.getHeight(),
114
+ source: ancestor
115
+ };
116
+ }
117
+ }, {
118
+ key: "intersectVisibilityRects",
119
+ value: function intersectVisibilityRects(a, b) {
120
+ return {
121
+ x: Math.max(a.x, b.x),
122
+ y: Math.max(a.y, b.y),
123
+ r: Math.min(a.r, b.r),
124
+ b: Math.min(a.b, b.b),
125
+ source: b.source
126
+ };
127
+ }
128
+ }, {
129
+ key: "updateClipRect",
130
+ value: function updateClipRect(tmodel) {
131
+ var parent = tmodel.getParent();
132
+ var inheritedClip = (parent === null || parent === void 0 ? void 0 : parent.visibilityClipRect) || null;
133
+ if (this.shouldClipByAncestor(tmodel)) {
134
+ var localRect = this.getLocalViewportRect(tmodel);
135
+ tmodel.visibilityClipRect = inheritedClip ? this.intersectVisibilityRects(inheritedClip, localRect) : localRect;
136
+ } else {
137
+ tmodel.visibilityClipRect = inheritedClip;
138
+ }
139
+ return tmodel.visibilityClipRect;
140
+ }
83
141
  }, {
84
142
  key: "contains",
85
143
  value: function contains(container, tmodel) {
@@ -305,9 +363,6 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
305
363
  }, {
306
364
  key: "runTargetValue",
307
365
  value: function runTargetValue(tmodel, target, key, cycle, lastValue) {
308
- if (_TargetParser.TargetParser.isIntervalTarget(target) && cycle === 1) {
309
- return;
310
- }
311
366
  var cleanKey = _TargetUtil.TargetUtil.getTargetName(key);
312
367
  var isExternalEvent = _TargetData.TargetData.allEventMap[cleanKey];
313
368
  if (isExternalEvent) {
@@ -266,7 +266,9 @@ _defineProperty(TargetData, "mustExecuteTargets", {
266
266
  heightFromDom: true,
267
267
  widthFromDom: true,
268
268
  fetch: true,
269
- fetchImage: true
269
+ fetchImage: true,
270
+ isVisible: true,
271
+ canDeleteDom: true
270
272
  });
271
273
  _defineProperty(TargetData, "ignoreRerun", {
272
274
  isVisible: true
@@ -899,5 +901,5 @@ _defineProperty(TargetData, "lifecyclePatterns", {
899
901
  });
900
902
  _defineProperty(TargetData, "eventSet", new Set([].concat(_toConsumableArray(Object.keys(_TargetData.allEventMap)), _toConsumableArray(Object.keys(_TargetData.internalEventMap)))));
901
903
  _defineProperty(TargetData, "styleSet", new Set([].concat(_toConsumableArray(Object.keys(_TargetData.styleTargetMap)), _toConsumableArray(Object.keys(_TargetData.asyncStyleTargetMap)), _toConsumableArray(Object.keys(_TargetData.attributeTargetMap)))));
902
- _defineProperty(TargetData, "reservedKeywordSet", new Set([].concat(_toConsumableArray(_TargetData.styleSet), _toConsumableArray(Object.keys(_TargetData.defaultActualValues())), _toConsumableArray(Object.keys(_TargetData.allEventMap)), _toConsumableArray(Object.keys(_TargetData.internalEventMap)), ['html', 'isInFlow', 'domHolder', 'domParent', 'gap', 'widthFromDom', 'heightFromDom', 'requiresDom', 'preventDefault', 'canDeleteDom', 'textOnly', 'styling', '$dom', 'defaultStyling', 'reuseDomDefinition', 'canHaveDom', 'excludeXYCalc', 'excludeX', 'excludeY', 'containerOverflowMode', 'itemOverflowMode', 'baseElement', 'element', 'otype', 'calculateChildren', 'domIsland', 'bracketThreshold', 'bracketSize', 'sourceDom'])));
904
+ _defineProperty(TargetData, "reservedKeywordSet", new Set([].concat(_toConsumableArray(_TargetData.styleSet), _toConsumableArray(Object.keys(_TargetData.defaultActualValues())), _toConsumableArray(Object.keys(_TargetData.allEventMap)), _toConsumableArray(Object.keys(_TargetData.internalEventMap)), _toConsumableArray(Object.keys(_TargetData.mustExecuteTargets)), ['html', 'isInFlow', 'domHolder', 'domParent', 'gap', 'widthFromDom', 'heightFromDom', 'requiresDom', 'preventDefault', 'canDeleteDom', 'textOnly', 'styling', '$dom', 'defaultStyling', 'reuseDomDefinition', 'canHaveDom', 'excludeXYCalc', 'excludeX', 'excludeY', 'containerOverflowMode', 'itemOverflowMode', 'baseElement', 'element', 'otype', 'calculateChildren', 'domIsland', 'bracketThreshold', 'bracketSize', 'shouldBeBracketed', 'sourceDom'])));
903
905
  _defineProperty(TargetData, "activationKeywordSet", new Set(['originalTModel', 'originalTargetName', 'activateNextTarget']));
@@ -90,7 +90,7 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
90
90
  targetValue = TargetExecutor.assignImperativeTargetValue(tmodel, key, originalTargetName, originalTModel);
91
91
  TargetExecutor.assignListTarget(tmodel, key, targetValue, value.list, value.list[0], vSteps, vInterval, vEasing, vCycles);
92
92
  } else if (_TargetParser.TargetParser.isTargetSpecObject(value)) {
93
- var valueArray = _TargetParser.TargetParser.getValueStepsCycles(tmodel, value, key);
93
+ var valueArray = _TargetParser.TargetParser.getValueStepsCycles(tmodel, key, value);
94
94
  var newValue = valueArray[0];
95
95
  var newSteps = valueArray[1];
96
96
  var newInterval = valueArray[2];
@@ -111,7 +111,7 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
111
111
  var newEasing = easing;
112
112
  var newCycles = cycles;
113
113
  if (_typeof(newValue) === 'object' && !_TargetParser.TargetParser.isListTarget(newValue)) {
114
- var _valueArray = _TargetParser.TargetParser.getValueStepsCycles(tmodel, completeValue[objectKey], objectKey);
114
+ var _valueArray = _TargetParser.TargetParser.getValueStepsCycles(tmodel, objectKey, completeValue[objectKey]);
115
115
  newValue = _valueArray[0];
116
116
  newSteps = _TUtil.TUtil.isDefined(_valueArray[1]) ? _valueArray[1] : steps;
117
117
  newInterval = _TUtil.TUtil.isDefined(_valueArray[2]) ? _valueArray[2] : interval;
@@ -122,7 +122,7 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
122
122
  });
123
123
  } else {
124
124
  if (_typeof(value) === 'object' && !_TargetParser.TargetParser.isListTarget(value)) {
125
- var _valueArray2 = _TargetParser.TargetParser.getValueStepsCycles(tmodel, value, key);
125
+ var _valueArray2 = _TargetParser.TargetParser.getValueStepsCycles(tmodel, key, value);
126
126
  if (value !== _valueArray2[0]) {
127
127
  value = _valueArray2[0];
128
128
  steps = _TUtil.TUtil.isDefined(_valueArray2[1]) ? _valueArray2[1] : steps;
@@ -248,8 +248,11 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
248
248
  key: "resolveTargetValue",
249
249
  value: function resolveTargetValue(tmodel, key) {
250
250
  var cycle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : tmodel.getTargetCycle(key);
251
+ if (_TargetParser.TargetParser.isIntervalTarget(tmodel.targets[key]) && cycle === 1) {
252
+ return;
253
+ }
251
254
  var targetInitial = !tmodel.targetValues[key] && _TUtil.TUtil.isDefined(tmodel.targets[key].initialValue) ? tmodel.targets[key].initialValue : undefined;
252
- var valueArray = _TargetParser.TargetParser.getValueStepsCycles(tmodel, tmodel.targets[key], key, cycle);
255
+ var valueArray = _TargetParser.TargetParser.getValueStepsCycles(tmodel, key, tmodel.targets[key], cycle);
253
256
  var newValue = valueArray[0];
254
257
  var newSteps = valueArray[1] || 0;
255
258
  var newInterval = valueArray[2] || 0;
@@ -259,7 +262,7 @@ var TargetExecutor = exports.TargetExecutor = /*#__PURE__*/function () {
259
262
  tmodel.targetValues[key] = targetValue;
260
263
  var easing = _TUtil.TUtil.isDefined(newEasing) ? newEasing : _TUtil.TUtil.isDefined(tmodel.targets[key].easing) ? tmodel.targets[key].easing : undefined;
261
264
  if (_TargetParser.TargetParser.isIntervalTarget(newValue)) {
262
- TargetExecutor.assignSingleTarget(targetValue, undefined, undefined, 0, 2, newValue.interval, easing);
265
+ TargetExecutor.assignSingleTarget(targetValue, undefined, targetInitial, 0, 2, newValue.interval, easing);
263
266
  } else if (_TargetParser.TargetParser.isChildTarget(key, newValue)) {
264
267
  tmodel.addChild(newValue);
265
268
  TargetExecutor.assignSingleTarget(targetValue, newValue, undefined, 0, newCycles, newInterval, easing);
@@ -243,7 +243,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
243
243
  });
244
244
  var isTransform = _TargetData.TargetData.isTransformKey(cleanKey);
245
245
  var getFrameAtTime = function getFrameAtTime(t) {
246
- var shifted = t + timeShift;
246
+ var shifted = Math.max(0, t + timeShift);
247
247
  for (var i = 0; i < batch.frames.length; i++) {
248
248
  var _frame = batch.frames[i];
249
249
  if (Math.abs(_frame.keyTime - shifted) < 0.0001) {
@@ -318,7 +318,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
318
318
  if (tmodel.getTargetEasing(key)) {
319
319
  batch.easing = tmodel.getTargetEasing(key);
320
320
  }
321
- batch.totalDuration = Math.max(batch.totalDuration, timeShift + keyDuration);
321
+ batch.totalDuration = Math.max(0, batch.totalDuration, timeShift + keyDuration);
322
322
  ((_batch$keyMap = batch.keyMap)[cleanKey] || (_batch$keyMap[cleanKey] = new Set())).add(key);
323
323
  tmodel.removeFromUpdatingTargets(key);
324
324
  return keyDuration;
@@ -217,7 +217,8 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
217
217
  }
218
218
  }, {
219
219
  key: "getValueStepsCycles",
220
- value: function getValueStepsCycles(tmodel, _target, key) {
220
+ value: function getValueStepsCycles(tmodel, key) {
221
+ var _target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : tmodel.targets[key];
221
222
  var cycle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : tmodel.getTargetCycle(key);
222
223
  var valueOnly = _target && _target.valueOnly;
223
224
  var lastValue = tmodel.val(key);
@@ -182,8 +182,8 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
182
182
  if (nextTarget) {
183
183
  if (isEndTrigger) {
184
184
  var _tmodel$targetValues$2, _tmodel$targetValues$3;
185
- var nextCompleteCount = (_tmodel$targetValues$2 = (_tmodel$targetValues$3 = tmodel.targetValues[nextTarget]) === null || _tmodel$targetValues$3 === void 0 ? void 0 : _tmodel$targetValues$3.completeCount) !== null && _tmodel$targetValues$2 !== void 0 ? _tmodel$targetValues$2 : 0;
186
- if (targetValue.completeCount > nextCompleteCount) {
185
+ var triggeredByCompleteCount = (_tmodel$targetValues$2 = (_tmodel$targetValues$3 = tmodel.targetValues[nextTarget]) === null || _tmodel$targetValues$3 === void 0 ? void 0 : _tmodel$targetValues$3.triggeredByCompleteCount) !== null && _tmodel$targetValues$2 !== void 0 ? _tmodel$targetValues$2 : 0;
186
+ if (targetValue.completeCount > triggeredByCompleteCount) {
187
187
  canActivate = true;
188
188
  }
189
189
  } else {
@@ -199,6 +199,7 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
199
199
  TargetUtil.activateTargetOnce(tmodel, nextTarget);
200
200
  nextTargetActivated = true;
201
201
  TargetUtil.clearPendingTargets(tmodel, key);
202
+ tmodel.targetValues[nextTarget].triggeredByCompleteCount = targetValue.completeCount;
202
203
  } else {
203
204
  TargetUtil.markPendingTargets(tmodel, key);
204
205
  }
@@ -219,6 +220,7 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
219
220
  TargetUtil.activateTarget(tmodel, nextTarget);
220
221
  nextTargetActivated = true;
221
222
  TargetUtil.clearPendingTargets(tmodel, key);
223
+ tmodel.targetValues[nextTarget].triggeredByCompleteCount = targetValue.completeCount;
222
224
  } else {
223
225
  TargetUtil.markPendingTargets(tmodel, key);
224
226
  }
@@ -716,7 +718,10 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
716
718
  var targetValue = tmodel.targetValues[key];
717
719
  if (targetValue) {
718
720
  targetValue.completeCount = 0;
721
+ targetValue.triggeredByCompleteCount = 0;
722
+ targetValue.resetFlag = true;
719
723
  targetValue.nextTargetUpdateCount = 0;
724
+ targetValue.status = 'complete';
720
725
  }
721
726
  tmodel.cancelAnimation();
722
727
  tmodel.activatedTargets.length = 0;