targetj 1.0.247 → 1.0.248

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) {
@@ -23,9 +23,8 @@ import { TargetUtil } from "./TargetUtil.js";
23
23
  import { TargetData } from "./TargetData.js";
24
24
  import { TModelUtil } from "./TModelUtil.js";
25
25
  import { ScheduleUtil } from "./ScheduleUtil.js";
26
- import { AnimationUtil } from "./AnimationUtil.js";
27
26
  import { TargetExecutor } from "./TargetExecutor.js";
28
- import { getTargetManager, tRoot, getEvents } from "./App.js";
27
+ import { getTargetManager, tRoot, getEvents, getAnimationManager } from "./App.js";
29
28
 
30
29
  /*
31
30
  * It calculates the locations and dimensions of all objects and triggers the calculation of all targets.
@@ -247,8 +246,8 @@ var LocationManager = /*#__PURE__*/function () {
247
246
  viewport.setLocation();
248
247
  child.markLayoutDirty('overflow');
249
248
  }
250
- var prevX = child.actualValues.x;
251
- var prevY = child.actualValues.y;
249
+ var prevX = Math.floor(child.actualValues.x);
250
+ var prevY = Math.floor(child.actualValues.y);
252
251
  if (child.isIncluded()) {
253
252
  _this.calculateTargets(child);
254
253
  }
@@ -626,20 +625,17 @@ var LocationManager = /*#__PURE__*/function () {
626
625
  key: "fixLocation",
627
626
  value: function fixLocation(tmodel, prevX, prevY) {
628
627
  if (tmodel.hasValidAnimation()) {
629
- var keysToSnap = [];
630
- var valuesToSnap = [];
631
- var xChanged = tmodel.actualValues.x !== prevX;
632
- var yChanged = tmodel.actualValues.y !== prevY;
628
+ var xChanged = Math.floor(tmodel.actualValues.x) !== prevX;
629
+ var yChanged = Math.floor(tmodel.actualValues.y) !== prevY;
630
+ var autoTfUpdates = {};
633
631
  if (xChanged && tmodel.getTargetStatus(tmodel.allTargetMap['x']) !== 'updating') {
634
- keysToSnap.push('x');
635
- valuesToSnap.push(tmodel.val('x'));
632
+ autoTfUpdates.x = tmodel.actualValues.x;
636
633
  }
637
634
  if (yChanged && tmodel.getTargetStatus(tmodel.allTargetMap['y']) !== 'updating') {
638
- keysToSnap.push('y');
639
- valuesToSnap.push(tmodel.val('y'));
635
+ autoTfUpdates.y = tmodel.actualValues.y;
640
636
  }
641
- if (keysToSnap.length > 0) {
642
- AnimationUtil.overrideAnimatedKeyWithSnap(tmodel, keysToSnap, valuesToSnap);
637
+ if (Object.keys(autoTfUpdates).length) {
638
+ getAnimationManager().rebaseAutoLayoutTransform(tmodel, autoTfUpdates);
643
639
  return;
644
640
  }
645
641
  }
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
  }, {