targetj 1.0.247 → 1.0.249

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.
@@ -77,7 +77,6 @@ var AnimationManager = /*#__PURE__*/function () {
77
77
  return;
78
78
  }
79
79
  var el = tmodel.$dom.getElement();
80
- this.cancelElementAnimationsForKeys(el, Object.keys(batch.keyMap));
81
80
  var totalDuration = Math.max(batch.totalDuration, 1);
82
81
  var originalKeys = _toConsumableArray(new Set(Object.values(batch.keyMap).flatMap(function (set) {
83
82
  return _toConsumableArray(set);
@@ -149,7 +148,7 @@ var AnimationManager = /*#__PURE__*/function () {
149
148
  var targetValue = tmodel.targetValues[_originalKey];
150
149
  if (targetValue) {
151
150
  tmodel.addToAnimatingMap(_originalKey);
152
- targetValue.status = !targetValue.snapAnimation ? 'updating' : targetValue.status;
151
+ targetValue.status = !targetValue.snapAnimation ? 'updating' : 'done';
153
152
  }
154
153
  this.recordMap.set(recId, rec);
155
154
  }
@@ -612,7 +611,8 @@ var AnimationManager = /*#__PURE__*/function () {
612
611
  }()
613
612
  }, {
614
613
  key: "fillCutFrameFromRecords",
615
- value: function fillCutFrameFromRecords(tmodel, cutFrame) {
614
+ value: function fillCutFrameFromRecords(tmodel, cutFrame, cutTime, totalDuration) {
615
+ var progress = totalDuration > 0 ? TUtil.limit(cutTime / totalDuration, 0, 1) : 1;
616
616
  var _iterator11 = _createForOfIteratorHelper(this.recordMap),
617
617
  _step11;
618
618
  try {
@@ -626,7 +626,7 @@ var AnimationManager = /*#__PURE__*/function () {
626
626
  if (record.status === 'canceled' || record.status === 'detached') {
627
627
  continue;
628
628
  }
629
- var result = AnimationUtil.getValueFromAnim(record);
629
+ var result = AnimationUtil.getValueFromFrames(record, progress);
630
630
  if (!result) {
631
631
  continue;
632
632
  }
@@ -643,6 +643,15 @@ var AnimationManager = /*#__PURE__*/function () {
643
643
  cycle: result.cycle,
644
644
  done: result.status === 'finished'
645
645
  });
646
+ this.setAt(tmodel, cleanKey, result.value);
647
+ tmodel.val(originalKey, result.value);
648
+ if (targetValue) {
649
+ targetValue.value = result.value;
650
+ targetValue.step = result.step;
651
+ targetValue.valuePointer = result.valuePointer;
652
+ targetValue.cycle = result.cycle;
653
+ tmodel.setActual(originalKey, result.value);
654
+ }
646
655
  }
647
656
  } catch (err) {
648
657
  _iterator11.e(err);
@@ -657,6 +666,7 @@ var AnimationManager = /*#__PURE__*/function () {
657
666
  while (i < batch.frames.length && batch.frames[i].keyTime <= cutTime) {
658
667
  i++;
659
668
  }
669
+ var originalDuration = batch.totalDuration;
660
670
  var needsInsert = i < batch.frames.length && cutTime !== batch.frames[i].keyTime;
661
671
  if (needsInsert) {
662
672
  var cutFrame = {
@@ -666,7 +676,7 @@ var AnimationManager = /*#__PURE__*/function () {
666
676
  keyMeta: new Map()
667
677
  };
668
678
  batch.frames.splice(i, 0, cutFrame);
669
- this.fillCutFrameFromRecords(tmodel, cutFrame);
679
+ this.fillCutFrameFromRecords(tmodel, cutFrame, cutTime, originalDuration);
670
680
  var originalKeys = _toConsumableArray(new Set(Object.values(batch.keyMap).flatMap(function (set) {
671
681
  return _toConsumableArray(set);
672
682
  })));
@@ -852,48 +862,24 @@ var AnimationManager = /*#__PURE__*/function () {
852
862
  return filtered;
853
863
  }
854
864
  }, {
855
- key: "cancelElementAnimationsForKeys",
856
- value: function cancelElementAnimationsForKeys(el, cleanKeys) {
857
- if (!el.getAnimations) {
858
- return;
865
+ key: "rebaseAutoLayoutTransform",
866
+ value: function rebaseAutoLayoutTransform(tmodel, tfUpdates) {
867
+ if (!tmodel.lastBatch) {
868
+ return false;
859
869
  }
860
- var keySet = new Set(cleanKeys);
861
- var _iterator18 = _createForOfIteratorHelper(el.getAnimations()),
870
+ var cutTime = Math.min(TUtil.now() - tmodel.lastBatch.startTime, tmodel.lastBatch.totalDuration);
871
+ var batch = this.cutLastBatch(tmodel, tmodel.lastBatch, cutTime);
872
+ AnimationUtil.rebaseCutBatchMeta(tmodel, batch);
873
+ var _iterator18 = _createForOfIteratorHelper(batch.frames),
862
874
  _step18;
863
875
  try {
864
876
  for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
865
- var anim = _step18.value;
866
- var effect = anim.effect;
867
- if (!(effect !== null && effect !== void 0 && effect.getKeyframes)) {
868
- continue;
869
- }
870
- var kfs = effect.getKeyframes();
871
- var touches = false;
872
- var _iterator19 = _createForOfIteratorHelper(kfs),
873
- _step19;
874
- try {
875
- for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
876
- var kf = _step19.value;
877
- for (var _i6 = 0, _Object$keys2 = Object.keys(kf); _i6 < _Object$keys2.length; _i6++) {
878
- var k = _Object$keys2[_i6];
879
- if (keySet.has(k)) {
880
- touches = true;
881
- break;
882
- }
883
- }
884
- if (touches) {
885
- break;
886
- }
887
- }
888
- } catch (err) {
889
- _iterator19.e(err);
890
- } finally {
891
- _iterator19.f();
892
- }
893
- if (touches) {
894
- try {
895
- anim.cancel();
896
- } catch (_unused) {}
877
+ var frame = _step18.value;
878
+ for (var _i7 = 0, _Object$entries3 = Object.entries(tfUpdates); _i7 < _Object$entries3.length; _i7++) {
879
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i7], 2),
880
+ _key2 = _Object$entries3$_i[0],
881
+ _value = _Object$entries3$_i[1];
882
+ frame.tfMap[_key2] = _value;
897
883
  }
898
884
  }
899
885
  } catch (err) {
@@ -901,6 +887,17 @@ var AnimationManager = /*#__PURE__*/function () {
901
887
  } finally {
902
888
  _iterator18.f();
903
889
  }
890
+ for (var _i6 = 0, _Object$entries2 = Object.entries(tfUpdates); _i6 < _Object$entries2.length; _i6++) {
891
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i6], 2),
892
+ key = _Object$entries2$_i[0],
893
+ value = _Object$entries2$_i[1];
894
+ tmodel.tfMap[key] = value;
895
+ tmodel.val(key, value);
896
+ tmodel.actualValues[key] = value;
897
+ }
898
+ this.deleteAnimation(tmodel);
899
+ this.animate(tmodel, batch, AnimationUtil.getAnimationHooks());
900
+ return true;
904
901
  }
905
902
  }]);
906
903
  }();
@@ -349,18 +349,24 @@ var AnimationUtil = /*#__PURE__*/function () {
349
349
  }, {
350
350
  key: "getValueFromAnim",
351
351
  value: function getValueFromAnim(record) {
352
- var _anim$effect, _anim$effect$getCompu, _right$segmentSteps, _ref3, _right$valuePointer2, _ref4, _right$cycle2;
353
- var originalKey = record.originalKey,
354
- anim = record.anim,
355
- frames = record.frames;
356
- if (!frames) {
352
+ var _record$anim$effect, _record$anim$effect$g;
353
+ var ct = (_record$anim$effect = record.anim.effect) === null || _record$anim$effect === void 0 || (_record$anim$effect$g = _record$anim$effect.getComputedTiming) === null || _record$anim$effect$g === void 0 ? void 0 : _record$anim$effect$g.call(_record$anim$effect);
354
+ if (!ct) {
357
355
  return;
358
356
  }
359
- var ct = (_anim$effect = anim.effect) === null || _anim$effect === void 0 || (_anim$effect$getCompu = _anim$effect.getComputedTiming) === null || _anim$effect$getCompu === void 0 ? void 0 : _anim$effect$getCompu.call(_anim$effect);
360
- if (!ct) {
357
+ var progress = TUtil.isDefined(ct.progress) ? TUtil.limit(ct.progress, 0, 1) : 1;
358
+ return AnimationUtil.getValueFromFrames(record, progress);
359
+ }
360
+ }, {
361
+ key: "getValueFromFrames",
362
+ value: function getValueFromFrames(record, progress) {
363
+ var _right$segmentSteps, _ref3, _right$valuePointer2, _ref4, _right$cycle2;
364
+ var originalKey = record.originalKey,
365
+ frames = record.frames;
366
+ if (!frames || frames.length < 2) {
361
367
  return;
362
368
  }
363
- var p = TUtil.isDefined(ct.progress) ? TUtil.limit(ct.progress, 0, 1) : 1;
369
+ var p = TUtil.limit(progress, 0, 1);
364
370
  var last = frames.length - 1;
365
371
  var framePointer = 0;
366
372
  if (p <= frames[0].offset) {
@@ -407,7 +413,6 @@ var AnimationUtil = /*#__PURE__*/function () {
407
413
  var stepOffset = right.stepOffset || 0;
408
414
  var segmentSteps = (_right$segmentSteps = right.segmentSteps) !== null && _right$segmentSteps !== void 0 ? _right$segmentSteps : stepOffset + remainingSteps;
409
415
  var step = TUtil.limit(stepOffset + localStep, 0, segmentSteps);
410
- var status = right.done ? "finished" : "playing";
411
416
  return {
412
417
  value: value,
413
418
  step: step,
@@ -416,7 +421,7 @@ var AnimationUtil = /*#__PURE__*/function () {
416
421
  cycle: (_ref4 = (_right$cycle2 = right.cycle) !== null && _right$cycle2 !== void 0 ? _right$cycle2 : left.cycle) !== null && _ref4 !== void 0 ? _ref4 : 0,
417
422
  from: from,
418
423
  to: to,
419
- status: status
424
+ status: right.done ? "finished" : "playing"
420
425
  };
421
426
  }
422
427
  }, {
@@ -1118,6 +1118,11 @@ var BaseModel = /*#__PURE__*/function () {
1118
1118
  this.animatingMap.set(key, true);
1119
1119
  (_this$getParent8 = this.getParent()) === null || _this$getParent8 === void 0 || _this$getParent8.addToAnimatingChildren(this);
1120
1120
  }
1121
+ }, {
1122
+ key: "getAnimatingTargets",
1123
+ value: function getAnimatingTargets() {
1124
+ return this.animatingMap ? _toConsumableArray(this.animatingMap.keys()) : [];
1125
+ }
1121
1126
  }, {
1122
1127
  key: "isKeyAnimating",
1123
1128
  value: function isKeyAnimating(key) {
@@ -3,6 +3,10 @@ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLim
3
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
5
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
6
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
9
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
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; } } }; }
7
11
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
12
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -23,9 +27,8 @@ import { TargetUtil } from "./TargetUtil.js";
23
27
  import { TargetData } from "./TargetData.js";
24
28
  import { TModelUtil } from "./TModelUtil.js";
25
29
  import { ScheduleUtil } from "./ScheduleUtil.js";
26
- import { AnimationUtil } from "./AnimationUtil.js";
27
30
  import { TargetExecutor } from "./TargetExecutor.js";
28
- import { getTargetManager, tRoot, getEvents } from "./App.js";
31
+ import { getTargetManager, tRoot, getEvents, getAnimationManager } from "./App.js";
29
32
 
30
33
  /*
31
34
  * It calculates the locations and dimensions of all objects and triggers the calculation of all targets.
@@ -247,8 +250,8 @@ var LocationManager = /*#__PURE__*/function () {
247
250
  viewport.setLocation();
248
251
  child.markLayoutDirty('overflow');
249
252
  }
250
- var prevX = child.actualValues.x;
251
- var prevY = child.actualValues.y;
253
+ var prevX = Math.floor(child.actualValues.x);
254
+ var prevY = Math.floor(child.actualValues.y);
252
255
  if (child.isIncluded()) {
253
256
  _this.calculateTargets(child);
254
257
  }
@@ -529,6 +532,16 @@ var LocationManager = /*#__PURE__*/function () {
529
532
  tmodel.markLayoutDirty('height');
530
533
  }
531
534
  }
535
+ if (tmodel.isNowVisible || tmodel.hasDomNow) {
536
+ var pending = tmodel.pendingTargets;
537
+ if (pending) {
538
+ for (var _i = 0, _arr = _toConsumableArray(pending); _i < _arr.length; _i++) {
539
+ var _key2 = _arr[_i];
540
+ TargetUtil.cleanupTarget(tmodel, _key2);
541
+ TargetUtil.shouldActivateNextTarget(tmodel, _key2);
542
+ }
543
+ }
544
+ }
532
545
  tmodel.isNowVisible = false;
533
546
  tmodel.hasDomNow = false;
534
547
  tmodel.targetExecutionCount++;
@@ -626,20 +639,17 @@ var LocationManager = /*#__PURE__*/function () {
626
639
  key: "fixLocation",
627
640
  value: function fixLocation(tmodel, prevX, prevY) {
628
641
  if (tmodel.hasValidAnimation()) {
629
- var keysToSnap = [];
630
- var valuesToSnap = [];
631
- var xChanged = tmodel.actualValues.x !== prevX;
632
- var yChanged = tmodel.actualValues.y !== prevY;
642
+ var xChanged = Math.floor(tmodel.actualValues.x) !== prevX;
643
+ var yChanged = Math.floor(tmodel.actualValues.y) !== prevY;
644
+ var autoTfUpdates = {};
633
645
  if (xChanged && tmodel.getTargetStatus(tmodel.allTargetMap['x']) !== 'updating') {
634
- keysToSnap.push('x');
635
- valuesToSnap.push(tmodel.val('x'));
646
+ autoTfUpdates.x = tmodel.actualValues.x;
636
647
  }
637
648
  if (yChanged && tmodel.getTargetStatus(tmodel.allTargetMap['y']) !== 'updating') {
638
- keysToSnap.push('y');
639
- valuesToSnap.push(tmodel.val('y'));
649
+ autoTfUpdates.y = tmodel.actualValues.y;
640
650
  }
641
- if (keysToSnap.length > 0) {
642
- AnimationUtil.overrideAnimatedKeyWithSnap(tmodel, keysToSnap, valuesToSnap);
651
+ if (Object.keys(autoTfUpdates).length) {
652
+ getAnimationManager().rebaseAutoLayoutTransform(tmodel, autoTfUpdates);
643
653
  return;
644
654
  }
645
655
  }
package/build/TModel.js CHANGED
@@ -571,11 +571,17 @@ var TModel = /*#__PURE__*/function (_BaseModel) {
571
571
  value: function debug() {
572
572
  var _this6 = this;
573
573
  return [{
574
+ oid: this.oid
575
+ }, {
574
576
  visible: this.isVisible()
575
577
  }, {
576
578
  visibilityStatus: this.visibilityStatus
577
579
  }, {
578
580
  hasDom: this.hasDom()
581
+ }, {
582
+ shouldCalculateChildren: this.shouldCalculateChildren()
583
+ }, {
584
+ dirtyLayout: this.getDirtyLayout()
579
585
  }, {
580
586
  x: this.getX()
581
587
  }, {
@@ -243,7 +243,7 @@ var TModelManager = /*#__PURE__*/function () {
243
243
  }
244
244
  var current = tmodel;
245
245
  while (current && current !== tRoot()) {
246
- var policy = current.val("domPolicy");
246
+ var policy = current.val("dom");
247
247
  if (TUtil.isDefined(policy)) {
248
248
  this.domPolicyMap.set(tmodel.oid, policy);
249
249
  return policy;
@@ -512,6 +512,7 @@ var TModelManager = /*#__PURE__*/function () {
512
512
  for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
513
513
  var tmodel = _step8.value;
514
514
  if (!tmodel.hasDom()) {
515
+ tmodel.markLayoutDirty('noDom');
515
516
  continue;
516
517
  }
517
518
  if (tmodel.noDomUpdatingTargets) {