@visactor/vrender-components 1.1.0-alpha.6 → 1.1.0-alpha.8

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.
Files changed (66) hide show
  1. package/cjs/animation/axis-animate.js +7 -3
  2. package/cjs/animation/axis-animate.js.map +1 -1
  3. package/cjs/animation/static-truth.d.ts +2 -0
  4. package/cjs/animation/static-truth.js +25 -0
  5. package/cjs/animation/static-truth.js.map +1 -0
  6. package/cjs/axis/animate/group-transition.d.ts +2 -2
  7. package/cjs/axis/animate/group-transition.js +7 -3
  8. package/cjs/axis/animate/group-transition.js.map +1 -1
  9. package/cjs/axis/base.js +21 -25
  10. package/cjs/axis/base.js.map +1 -1
  11. package/cjs/axis/index.js +1 -2
  12. package/cjs/axis/line.js +2 -1
  13. package/cjs/crosshair/polygon.js +1 -2
  14. package/cjs/crosshair/rect.js +2 -1
  15. package/cjs/data-zoom/index.js +1 -2
  16. package/cjs/index.d.ts +1 -1
  17. package/cjs/index.js +1 -1
  18. package/cjs/index.js.map +1 -1
  19. package/cjs/indicator/config.js +2 -1
  20. package/cjs/label/arc.js +1 -1
  21. package/cjs/label/base.js +4 -2
  22. package/cjs/label/base.js.map +1 -1
  23. package/cjs/legend/discrete/discrete.js +13 -7
  24. package/cjs/legend/discrete/discrete.js.map +1 -1
  25. package/cjs/marker/animate/call-in.js +6 -2
  26. package/cjs/marker/animate/call-in.js.map +1 -1
  27. package/cjs/marker/animate/clip-in.js +6 -2
  28. package/cjs/marker/animate/clip-in.js.map +1 -1
  29. package/cjs/marker/animate/common.js +14 -5
  30. package/cjs/marker/animate/common.js.map +1 -1
  31. package/cjs/timeline/timeline.js +35 -12
  32. package/cjs/timeline/timeline.js.map +1 -1
  33. package/dist/index.es.js +165 -44
  34. package/es/animation/axis-animate.js +8 -3
  35. package/es/animation/axis-animate.js.map +1 -1
  36. package/es/animation/static-truth.d.ts +2 -0
  37. package/es/animation/static-truth.js +18 -0
  38. package/es/animation/static-truth.js.map +1 -0
  39. package/es/axis/animate/group-transition.d.ts +2 -2
  40. package/es/axis/animate/group-transition.js +7 -2
  41. package/es/axis/animate/group-transition.js.map +1 -1
  42. package/es/axis/base.js +22 -24
  43. package/es/axis/base.js.map +1 -1
  44. package/es/axis/index.js +1 -2
  45. package/es/axis/line.js +2 -1
  46. package/es/crosshair/polygon.js +1 -2
  47. package/es/crosshair/rect.js +2 -1
  48. package/es/data-zoom/index.js +1 -2
  49. package/es/index.d.ts +1 -1
  50. package/es/index.js +1 -1
  51. package/es/index.js.map +1 -1
  52. package/es/indicator/config.js +2 -1
  53. package/es/label/arc.js +1 -1
  54. package/es/label/base.js +5 -1
  55. package/es/label/base.js.map +1 -1
  56. package/es/legend/discrete/discrete.js +14 -6
  57. package/es/legend/discrete/discrete.js.map +1 -1
  58. package/es/marker/animate/call-in.js +7 -2
  59. package/es/marker/animate/call-in.js.map +1 -1
  60. package/es/marker/animate/clip-in.js +7 -2
  61. package/es/marker/animate/clip-in.js.map +1 -1
  62. package/es/marker/animate/common.js +10 -2
  63. package/es/marker/animate/common.js.map +1 -1
  64. package/es/timeline/timeline.js +36 -11
  65. package/es/timeline/timeline.js.map +1 -1
  66. package/package.json +5 -5
package/dist/index.es.js CHANGED
@@ -5240,11 +5240,23 @@ class StateTransitionOrchestrator {
5240
5240
  if (!hasAnimation) return plan;
5241
5241
  const noWorkAnimateAttr = Object.assign(Object.assign({}, null !== (_a = options.noWorkAnimateAttr) && void 0 !== _a ? _a : {}), normalizeNoAnimateAttrConfig(null === (_b = options.animateConfig) || void 0 === _b ? void 0 : _b.noAnimateAttrs)),
5242
5242
  isClear = !0 === options.isClear,
5243
- getDefaultAttribute = options.getDefaultAttribute;
5243
+ getDefaultAttribute = options.getDefaultAttribute,
5244
+ shouldSkipDefaultAttribute = options.shouldSkipDefaultAttribute,
5245
+ assignTransitionAttr = (key, value) => {
5246
+ if (noWorkAnimateAttr[key]) return plan.jumpAttrs[key] = value, void (plan.noAnimateAttrs[key] = value);
5247
+ if (isClear && void 0 === value) {
5248
+ if (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, targetAttrs)) return;
5249
+ plan.animateAttrs[key] = getDefaultAttribute ? getDefaultAttribute(key) : value;
5250
+ } else plan.animateAttrs[key] = value;
5251
+ };
5244
5252
  for (const key in targetAttrs) {
5245
5253
  if (!Object.prototype.hasOwnProperty.call(targetAttrs, key)) continue;
5246
- const value = targetAttrs[key];
5247
- noWorkAnimateAttr[key] ? (plan.jumpAttrs[key] = value, plan.noAnimateAttrs[key] = value) : plan.animateAttrs[key] = isClear && void 0 === value && getDefaultAttribute ? getDefaultAttribute(key) : value;
5254
+ assignTransitionAttr(key, targetAttrs[key]);
5255
+ }
5256
+ const extraAnimateAttrs = options.extraAnimateAttrs;
5257
+ if (extraAnimateAttrs) for (const key in extraAnimateAttrs) {
5258
+ const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetAttrs, key);
5259
+ !Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key]);
5248
5260
  }
5249
5261
  return plan;
5250
5262
  }
@@ -5271,12 +5283,14 @@ class StateTransitionOrchestrator {
5271
5283
  }), plan;
5272
5284
  }
5273
5285
  applyClearTransition(graphic, targetAttrs, hasAnimation, stateNames, options = {}) {
5274
- var _a, _b;
5286
+ var _a, _b, _c, _d;
5275
5287
  const plan = this.analyzeTransition({}, targetAttrs, stateNames, hasAnimation, {
5276
5288
  noWorkAnimateAttr: null === (_a = graphic.getNoWorkAnimateAttr) || void 0 === _a ? void 0 : _a.call(graphic),
5277
5289
  isClear: !0,
5278
5290
  getDefaultAttribute: null === (_b = graphic.getDefaultAttribute) || void 0 === _b ? void 0 : _b.bind(graphic),
5279
- animateConfig: options.animateConfig
5291
+ shouldSkipDefaultAttribute: null !== (_c = options.shouldSkipDefaultAttribute) && void 0 !== _c ? _c : null === (_d = graphic.shouldSkipStateTransitionDefaultAttribute) || void 0 === _d ? void 0 : _d.bind(graphic),
5292
+ animateConfig: options.animateConfig,
5293
+ extraAnimateAttrs: options.extraAnimateAttrs
5280
5294
  });
5281
5295
  return this.applyTransition(graphic, plan, hasAnimation, options);
5282
5296
  }
@@ -5592,13 +5606,22 @@ class Graphic extends Node {
5592
5606
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
5593
5607
  }), snapshot) : snapshot;
5594
5608
  }
5595
- buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
5596
- const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
5597
- if (!previousResolvedStatePatch) return targetAttrs;
5598
- const snapshot = this.buildStaticAttributeSnapshot();
5609
+ buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
5610
+ const extraAttrs = {};
5611
+ if (!previousResolvedStatePatch) return extraAttrs;
5612
+ const snapshot = this.buildStaticAttributeSnapshot(),
5613
+ staticTargetAttrs = snapshot;
5599
5614
  return Object.keys(previousResolvedStatePatch).forEach(key => {
5600
- Object.prototype.hasOwnProperty.call(targetAttrs, key) || (targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key) ? cloneAttributeValue(snapshot[key]) : this.getDefaultAttribute(key));
5601
- }), targetAttrs;
5615
+ const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
5616
+ if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
5617
+ const assignFallbackAttr = value => {
5618
+ void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
5619
+ };
5620
+ if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
5621
+ const snapshotValue = snapshot[key];
5622
+ assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
5623
+ } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
5624
+ }), extraAttrs;
5602
5625
  }
5603
5626
  syncObjectToSnapshot(target, snapshot) {
5604
5627
  const delta = new Map();
@@ -6021,21 +6044,31 @@ class Graphic extends Node {
6021
6044
  var _a, _b, _c;
6022
6045
  return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : DefaultStateAnimateConfig;
6023
6046
  }
6024
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
6047
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
6025
6048
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0,
6026
6049
  transitionOptions = resolvedAnimateConfig ? {
6027
- animateConfig: resolvedAnimateConfig
6050
+ animateConfig: resolvedAnimateConfig,
6051
+ extraAnimateAttrs: extraAnimateAttrs,
6052
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
6028
6053
  } : void 0;
6029
6054
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
6030
6055
  const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
6031
6056
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
6032
- animateConfig: resolvedAnimateConfig
6057
+ animateConfig: resolvedAnimateConfig,
6058
+ extraAnimateAttrs: extraAnimateAttrs,
6059
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
6033
6060
  });
6034
6061
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
6035
6062
  }
6036
6063
  updateNormalAttrs(stateAttrs) {
6037
6064
  this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
6038
6065
  }
6066
+ getStateTransitionDefaultAttribute(key, targetAttrs) {
6067
+ return this.getDefaultAttribute(key);
6068
+ }
6069
+ shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
6070
+ return !1;
6071
+ }
6039
6072
  stopStateAnimates(type = "end") {
6040
6073
  const stopAnimationState = this.stopAnimationState;
6041
6074
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
@@ -6052,13 +6085,14 @@ class Graphic extends Node {
6052
6085
  clearStates(hasAnimation) {
6053
6086
  var _a, _b, _c;
6054
6087
  const previousStates = this.currentStates ? this.currentStates.slice() : [],
6088
+ previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0,
6055
6089
  transition = this.createStateModel().clearStates();
6056
6090
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
6057
6091
  const resolvedStateAttrs = cloneAttributeValue(null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {});
6058
6092
  transition.changed && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0) || (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), null === (_b = getStageStatePerfMonitor(this.stage)) || void 0 === _b || _b.incrementCounter("stateCommits"), null === (_c = getStageStatePerfMonitor(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
6059
6093
  graphicId: this._uid,
6060
6094
  targetStates: []
6061
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0)) : (this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
6095
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
6062
6096
  type: AttributeUpdateType.STATE
6063
6097
  }), this._emitCustomEvent("afterStateUpdate", {
6064
6098
  type: AttributeUpdateType.STATE
@@ -6091,7 +6125,7 @@ class Graphic extends Node {
6091
6125
  this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs), this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), null === (_d = getStageStatePerfMonitor(this.stage)) || void 0 === _d || _d.incrementCounter("stateCommits"), null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
6092
6126
  graphicId: this._uid,
6093
6127
  targetStates: [...transition.states]
6094
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation)) : (this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
6128
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
6095
6129
  type: AttributeUpdateType.STATE
6096
6130
  }), this._emitCustomEvent("afterStateUpdate", {
6097
6131
  type: AttributeUpdateType.STATE
@@ -7510,6 +7544,52 @@ class Rect extends Graphic {
7510
7544
  needUpdateTag(key) {
7511
7545
  return super.needUpdateTag(key, RECT_UPDATE_TAG_KEY);
7512
7546
  }
7547
+ shouldSkipStateTransitionDefaultAttribute(key, targetAttrs) {
7548
+ var _a;
7549
+ const attrs = null !== (_a = null != targetAttrs ? targetAttrs : this.baseAttributes) && void 0 !== _a ? _a : this.attribute,
7550
+ hasValue = attrKey => null != attrs[attrKey],
7551
+ isNilValue = attrKey => null == attrs[attrKey];
7552
+ switch (key) {
7553
+ case "width":
7554
+ return isNilValue("width") && hasValue("x") && hasValue("x1");
7555
+ case "height":
7556
+ return isNilValue("height") && hasValue("y") && hasValue("y1");
7557
+ case "x1":
7558
+ return isNilValue("x1") && hasValue("x") && hasValue("width");
7559
+ case "y1":
7560
+ return isNilValue("y1") && hasValue("y") && hasValue("height");
7561
+ default:
7562
+ return !1;
7563
+ }
7564
+ }
7565
+ getStateTransitionDefaultAttribute(key, targetAttrs) {
7566
+ var _a;
7567
+ const attrs = null !== (_a = null != targetAttrs ? targetAttrs : this.baseAttributes) && void 0 !== _a ? _a : this.attribute,
7568
+ getNumber = attrKey => {
7569
+ const value = attrs[attrKey];
7570
+ return "number" == typeof value && Number.isFinite(value) ? value : void 0;
7571
+ },
7572
+ x = getNumber("x"),
7573
+ y = getNumber("y"),
7574
+ x1 = getNumber("x1"),
7575
+ y1 = getNumber("y1"),
7576
+ width = getNumber("width"),
7577
+ height = getNumber("height");
7578
+ switch (key) {
7579
+ case "width":
7580
+ if (null == width && null != x && null != x1) return x1 - x;
7581
+ break;
7582
+ case "height":
7583
+ if (null == height && null != y && null != y1) return y1 - y;
7584
+ break;
7585
+ case "x1":
7586
+ if (null == x1 && null != x && null != width) return x + width;
7587
+ break;
7588
+ case "y1":
7589
+ if (null == y1 && null != y && null != height) return y + height;
7590
+ }
7591
+ return super.getStateTransitionDefaultAttribute(key, targetAttrs);
7592
+ }
7513
7593
  toCustomPath() {
7514
7594
  let path = super.toCustomPath();
7515
7595
  if (path) return path;
@@ -18250,6 +18330,26 @@ class AnimateComponent extends AbstractComponent {
18250
18330
  }
18251
18331
  }
18252
18332
 
18333
+ function commitUpdateAnimationTarget(graphic, targetAttrs, startAttrs) {
18334
+ var _a, _b, _c, _d;
18335
+ if (!graphic || !targetAttrs) {
18336
+ return;
18337
+ }
18338
+ const committedTargetAttrs = cloneDeep(targetAttrs);
18339
+ const transientStartAttrs = cloneDeep(startAttrs !== null && startAttrs !== void 0 ? startAttrs : graphic.attribute);
18340
+ graphic.setAttributes(committedTargetAttrs);
18341
+ const baseAttributes = graphic.baseAttributes;
18342
+ if (baseAttributes && typeof baseAttributes === 'object') {
18343
+ Object.keys(committedTargetAttrs).forEach(key => {
18344
+ baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);
18345
+ });
18346
+ }
18347
+ (_b = (_a = graphic).setFinalAttributes) === null || _b === void 0 ? void 0 : _b.call(_a, committedTargetAttrs);
18348
+ (_d = (_c = graphic).setAttributesAndPreventAnimate) === null || _d === void 0 ? void 0 : _d.call(_c, transientStartAttrs, false, {
18349
+ type: AttributeUpdateType.ANIMATE_BIND
18350
+ });
18351
+ }
18352
+
18253
18353
  const DefaultAxisAnimation = {
18254
18354
  type: 'default',
18255
18355
  duration: 300,
@@ -18651,11 +18751,10 @@ class AxisBase extends AnimateComponent {
18651
18751
  var _a;
18652
18752
  if (el.type !== 'group' && el.id) {
18653
18753
  const oldEl = prevInnerView[el.id];
18654
- el.setFinalAttributes(el.attribute);
18655
18754
  if (oldEl) {
18656
18755
  oldEl.release();
18657
- const oldAttrs = oldEl.attribute;
18658
- const finalAttrs = el.getFinalAttribute();
18756
+ const oldAttrs = cloneDeep(oldEl.attribute);
18757
+ const finalAttrs = cloneDeep(el.attribute);
18659
18758
  const diffAttrs = diff(oldAttrs, finalAttrs);
18660
18759
  let hasDiff = Object.keys(diffAttrs).length > 0;
18661
18760
  if ('opacity' in oldAttrs && finalAttrs.opacity !== oldAttrs.opacity) {
@@ -18666,10 +18765,9 @@ class AxisBase extends AnimateComponent {
18666
18765
  this._newElementAttrMap[el.id] = {
18667
18766
  state: 'update',
18668
18767
  node: el,
18669
- attrs: el.attribute
18768
+ attrs: finalAttrs
18670
18769
  };
18671
- const oldAttrs = oldEl.attribute;
18672
- el.setAttributes(oldAttrs);
18770
+ commitUpdateAnimationTarget(el, finalAttrs, oldAttrs);
18673
18771
  el.applyAnimationState(['update'], [
18674
18772
  {
18675
18773
  name: 'update',
@@ -19843,7 +19941,7 @@ class Animate {
19843
19941
  if (nextTime >= this._startTime + this._totalDuration) {
19844
19942
  null === (_a = this._lastStep) || void 0 === _a || _a.onUpdate(!0, 1, {}), null === (_b = this._lastStep) || void 0 === _b || _b.onEnd(), this.onEnd(), this.status = AnimateStatus.END;
19845
19943
  const trackerTarget = this.target;
19846
- return void ("function" == typeof (null == trackerTarget ? void 0 : trackerTarget.restoreStaticAttribute) && trackerTarget.restoreStaticAttribute());
19944
+ return "function" == typeof (null == trackerTarget ? void 0 : trackerTarget.restoreStaticAttribute) && trackerTarget.restoreStaticAttribute(), void (this.__skipRestoreStaticAttributeOnRemove = !0);
19847
19945
  }
19848
19946
  this.status = AnimateStatus.RUNNING, this.currentTime <= this._startTime && this.onStart(), this.currentTime = nextTime;
19849
19947
  let cycleTime = nextTime - this._startTime,
@@ -20852,7 +20950,7 @@ class AxisEnter extends AComponentAnimate {
20852
20950
  const point = getTickCoord(oldValue);
20853
20951
  const newX = this.target.attribute.x;
20854
20952
  const newY = this.target.attribute.y;
20855
- this.target.setAttributes({ x: point.x, y: point.y });
20953
+ commitUpdateAnimationTarget(this.target, { x: newX, y: newY }, { x: point.x, y: point.y });
20856
20954
  animator.animate(this.target, {
20857
20955
  type: 'to',
20858
20956
  to: { x: newX, y: newY },
@@ -20875,7 +20973,8 @@ class AxisUpdate extends AComponentAnimate {
20875
20973
  this._animator = animator;
20876
20974
  const duration = this.duration;
20877
20975
  const easing = this.easing;
20878
- const { config, diffAttrs } = this.params;
20976
+ const { diffAttrs } = this.params;
20977
+ commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs));
20879
20978
  animator.animate(this.target, {
20880
20979
  type: 'to',
20881
20980
  to: Object.assign({}, diffAttrs),
@@ -21922,6 +22021,7 @@ class GroupTransition extends ACustomAnimate {
21922
22021
  this.mode = AnimateMode.NORMAL;
21923
22022
  }
21924
22023
  onBind() {
22024
+ this._started = false;
21925
22025
  const currentInnerView = this.target.getInnerView();
21926
22026
  const prevInnerView = this.target.getPrevInnerView();
21927
22027
  if (!prevInnerView) {
@@ -21940,7 +22040,7 @@ class GroupTransition extends ACustomAnimate {
21940
22040
  node: el,
21941
22041
  attrs: Object.assign(Object.assign({}, newProps), { opacity: (_a = newProps.opacity) !== null && _a !== void 0 ? _a : 1, fillOpacity: (_b = newProps.fillOpacity) !== null && _b !== void 0 ? _b : 1, strokeOpacity: (_c = newProps.strokeOpacity) !== null && _c !== void 0 ? _c : 1 })
21942
22042
  };
21943
- el.setAttributes(oldEl.attribute);
22043
+ commitUpdateAnimationTarget(el, this._newElementAttrMap[el.id].attrs, cloneDeep(oldEl.attribute));
21944
22044
  }
21945
22045
  }
21946
22046
  else {
@@ -21954,7 +22054,7 @@ class GroupTransition extends ACustomAnimate {
21954
22054
  node: el,
21955
22055
  attrs: finalOpacityAttrs
21956
22056
  };
21957
- el.setAttributes({
22057
+ commitUpdateAnimationTarget(el, finalOpacityAttrs, {
21958
22058
  opacity: 0,
21959
22059
  fillOpacity: 0,
21960
22060
  strokeOpacity: 0
@@ -21964,6 +22064,10 @@ class GroupTransition extends ACustomAnimate {
21964
22064
  });
21965
22065
  }
21966
22066
  onStart() {
22067
+ if (this._started) {
22068
+ return;
22069
+ }
22070
+ this._started = true;
21967
22071
  let duration = this.duration;
21968
22072
  let easing = this.easing;
21969
22073
  this._newElementAttrMap &&
@@ -24079,6 +24183,8 @@ class LabelBase extends AnimateComponent {
24079
24183
  _runUpdateAnimation(prevLabel, currentLabel) {
24080
24184
  const { text: prevText, labelLine: prevLabelLine } = prevLabel;
24081
24185
  const { text: curText, labelLine: curLabelLine } = currentLabel;
24186
+ commitUpdateAnimationTarget(prevText, curText === null || curText === void 0 ? void 0 : curText.attribute);
24187
+ commitUpdateAnimationTarget(prevLabelLine, curLabelLine === null || curLabelLine === void 0 ? void 0 : curLabelLine.attribute);
24082
24188
  prevText.applyAnimationState(['update'], [
24083
24189
  {
24084
24190
  name: 'update',
@@ -24110,7 +24216,7 @@ class LabelBase extends AnimateComponent {
24110
24216
  this.runEnterAnimation(text, labelLine);
24111
24217
  }
24112
24218
  _updateLabel(prevLabel, currentLabel) {
24113
- const { text: prevText, labelLine: prevLabelLine } = prevLabel;
24219
+ const { labelLine: prevLabelLine } = prevLabel;
24114
24220
  const { text: curText, labelLine: curLabelLine } = currentLabel;
24115
24221
  if (this._enableAnimation === false || this._animationConfig.update === false) {
24116
24222
  prevLabel.text.setAttributes(curText.attribute);
@@ -27006,7 +27112,10 @@ function graphicFadeIn(graphic, delay, duration, easing) {
27006
27112
  (_a = graphic === null || graphic === void 0 ? void 0 : graphic.animates) === null || _a === void 0 ? void 0 : _a.forEach(a => a.stop('end'));
27007
27113
  const fillOpacityConfig = (_c = (_b = graphic.attribute) === null || _b === void 0 ? void 0 : _b.fillOpacity) !== null && _c !== void 0 ? _c : 1;
27008
27114
  const strokeOpacityConfig = (_e = (_d = graphic.attribute) === null || _d === void 0 ? void 0 : _d.strokeOpacity) !== null && _e !== void 0 ? _e : 1;
27009
- graphic.setAttributes({
27115
+ commitUpdateAnimationTarget(graphic, {
27116
+ fillOpacity: fillOpacityConfig,
27117
+ strokeOpacity: strokeOpacityConfig
27118
+ }, {
27010
27119
  fillOpacity: 0,
27011
27120
  strokeOpacity: 0
27012
27121
  });
@@ -27036,7 +27145,10 @@ function graphicFadeOut(graphic, delay, duration, easing) {
27036
27145
  if (!graphic) {
27037
27146
  return;
27038
27147
  }
27039
- graphic.setAttributes({
27148
+ commitUpdateAnimationTarget(graphic, {
27149
+ fillOpacity: 0,
27150
+ strokeOpacity: 0
27151
+ }, {
27040
27152
  fillOpacity: (_b = (_a = graphic.attribute) === null || _a === void 0 ? void 0 : _a.fillOpacity) !== null && _b !== void 0 ? _b : 1,
27041
27153
  strokeOpacity: (_d = (_c = graphic.attribute) === null || _c === void 0 ? void 0 : _c.strokeOpacity) !== null && _d !== void 0 ? _d : 1
27042
27154
  });
@@ -27065,7 +27177,7 @@ function commonLineClipIn(line, label, duration, delay, easing) {
27065
27177
  const endSymbolDuration = 0.1 * duration;
27066
27178
  const labelDuration = 0.1 * duration;
27067
27179
  graphicFadeIn(line.startSymbol, delay, startSymbolDuration, easing);
27068
- line.lines.forEach(line => line.setAttribute('clipRange', 0));
27180
+ line.lines.forEach(line => commitUpdateAnimationTarget(line, { clipRange: 1 }, { clipRange: 0 }));
27069
27181
  line.lines.forEach((l, index) => {
27070
27182
  const stepDuration = lineDuration / line.lines.length;
27071
27183
  l.animate()
@@ -27148,7 +27260,7 @@ function pointCallIn(itemLine, decorativeLine, item, duration, delay, easing) {
27148
27260
  const endSymbolDuration = 0.1 * duration;
27149
27261
  const labelDuration = 0.1 * duration;
27150
27262
  graphicFadeIn(itemLine.startSymbol, delay, startSymbolDuration, easing);
27151
- itemLine.lines.forEach(line => line.setAttribute('clipRange', 0));
27263
+ itemLine.lines.forEach(line => commitUpdateAnimationTarget(line, { clipRange: 1 }, { clipRange: 0 }));
27152
27264
  itemLine.lines.forEach((l, index) => {
27153
27265
  const stepDuration = lineDuration / itemLine.lines.length;
27154
27266
  l.animate()
@@ -29647,9 +29759,9 @@ class DiscreteLegend extends LegendBase {
29647
29759
  }
29648
29760
  if (!this._itemContext.isScrollbar) {
29649
29761
  if (animation) {
29650
- this._itemsContainer
29651
- .animate()
29652
- .to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
29762
+ const attrs = { [channel]: -(newPage - 1) * pageSize };
29763
+ commitUpdateAnimationTarget(this._itemsContainer, attrs);
29764
+ this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
29653
29765
  }
29654
29766
  else {
29655
29767
  this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
@@ -29667,7 +29779,9 @@ class DiscreteLegend extends LegendBase {
29667
29779
  const startOffset = containerSize * start;
29668
29780
  this.updateScrollMask();
29669
29781
  if (animation) {
29670
- this._itemsContainer.animate().to({ [channel]: -startOffset }, animationDuration, animationEasing);
29782
+ const attrs = { [channel]: -startOffset };
29783
+ commitUpdateAnimationTarget(this._itemsContainer, attrs);
29784
+ this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
29671
29785
  }
29672
29786
  else {
29673
29787
  this._itemsContainer.setAttribute(channel, -startOffset);
@@ -33620,6 +33734,7 @@ class Timeline extends AbstractComponent {
33620
33734
  setActive(symbolGroup, activeSymbolStyle);
33621
33735
  }
33622
33736
  appearAnimate(animateConfig) {
33737
+ var _a;
33623
33738
  const { duration = 1000, easing = 'quadOut' } = animateConfig;
33624
33739
  const { activeLabelStyle, activeSymbolStyle } = this.attribute;
33625
33740
  const percent = duration / 1000;
@@ -33630,30 +33745,33 @@ class Timeline extends AbstractComponent {
33630
33745
  const symbolDelay = percent * 100;
33631
33746
  const symbolNormalDelay = percent * 600;
33632
33747
  if (this._line) {
33633
- this._line.setAttributes({ clipRange: 0 });
33748
+ commitUpdateAnimationTarget(this._line, { clipRange: 1 }, { clipRange: 0 });
33634
33749
  this._line.animate().to({ clipRange: 1 }, lineDuration, easing);
33635
33750
  }
33636
33751
  if (this._activeLine) {
33637
- this._activeLine.setAttributes({ opacity: 0 });
33752
+ const opacity = (_a = this._activeLine.attribute.opacity) !== null && _a !== void 0 ? _a : 1;
33753
+ commitUpdateAnimationTarget(this._activeLine, { opacity }, { opacity: 0 });
33638
33754
  this._activeLine
33639
33755
  .animate()
33640
33756
  .wait(500)
33641
- .to({ opacity: 1 }, activeLineDuration, easing);
33757
+ .to({ opacity }, activeLineDuration, easing);
33642
33758
  }
33643
33759
  if (this._symbolGroup) {
33644
33760
  const size = this._symbolGroup.count - 1;
33645
33761
  const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));
33646
33762
  const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));
33647
33763
  this._symbolGroup.forEachChildren((symbol, i) => {
33764
+ var _a;
33648
33765
  const originAttrs = {};
33649
33766
  Object.keys(activeSymbolStyle).forEach(k => {
33650
33767
  originAttrs[k] = symbol.attribute[k];
33651
33768
  });
33652
- symbol.setAttributes({ opacity: 0 });
33769
+ const opacity = (_a = symbol.attribute.opacity) !== null && _a !== void 0 ? _a : 1;
33770
+ commitUpdateAnimationTarget(symbol, { opacity }, { opacity: 0 });
33653
33771
  symbol
33654
33772
  .animate()
33655
33773
  .wait(symbolDelay + delay * i)
33656
- .to({ opacity: 1 }, perSymbolDuration, easing);
33774
+ .to({ opacity }, perSymbolDuration, easing);
33657
33775
  symbol
33658
33776
  .animate()
33659
33777
  .wait(symbolNormalDelay + delayNormal * i)
@@ -33666,15 +33784,17 @@ class Timeline extends AbstractComponent {
33666
33784
  const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));
33667
33785
  const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));
33668
33786
  this._labelGroup.forEachChildren((label, i) => {
33787
+ var _a;
33669
33788
  const originAttrs = {};
33670
33789
  Object.keys(activeLabelStyle).forEach(k => {
33671
33790
  originAttrs[k] = label.attribute[k];
33672
33791
  });
33673
- label.setAttributes({ opacity: 0 });
33792
+ const opacity = (_a = label.attribute.opacity) !== null && _a !== void 0 ? _a : 1;
33793
+ commitUpdateAnimationTarget(label, { opacity }, { opacity: 0 });
33674
33794
  label
33675
33795
  .animate()
33676
33796
  .wait(symbolDelay + delay * i)
33677
- .to({ opacity: 1 }, perSymbolDuration, easing);
33797
+ .to({ opacity }, perSymbolDuration, easing);
33678
33798
  label
33679
33799
  .animate()
33680
33800
  .wait(symbolNormalDelay + delayNormal * i)
@@ -33714,6 +33834,7 @@ class Timeline extends AbstractComponent {
33714
33834
  const nextClipRange = flag > 0 ? this._timesPercent[i] || 1 : this._timesPercent[i - 1] || 0;
33715
33835
  if (animation) {
33716
33836
  const { duration = 1000, easing = 'quadOut' } = animateConfig;
33837
+ commitUpdateAnimationTarget(this, { clipRange: nextClipRange }, { clipRange });
33717
33838
  this.animate().to({ clipRange: nextClipRange }, duration, easing);
33718
33839
  }
33719
33840
  else {
@@ -35560,6 +35681,6 @@ TableSeriesNumber.defaultAttributes = {
35560
35681
  select: true
35561
35682
  };
35562
35683
 
35563
- const version = "1.1.0-alpha.6";
35684
+ const version = "1.1.0-alpha.8";
35564
35685
 
35565
35686
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IDataZoomEvent, IDataZoomInteractiveEvent, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SeriesNumberCellStateValue, SeriesNumberEvent, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, TableSeriesNumber, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, installPoptipToApp, installScrollbarToApp, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
@@ -1,5 +1,7 @@
1
1
  import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from "@visactor/vrender-animate";
2
2
 
3
+ import { commitUpdateAnimationTarget } from "./static-truth";
4
+
3
5
  export class AxisEnter extends AComponentAnimate {
4
6
  onBind() {
5
7
  var _a;
@@ -11,7 +13,10 @@ export class AxisEnter extends AComponentAnimate {
11
13
  if (lastScale && getTickCoord && currData) {
12
14
  ratio = .7;
13
15
  const point = getTickCoord(lastScale.scale(currData.rawValue)), newX = this.target.attribute.x, newY = this.target.attribute.y;
14
- this.target.setAttributes({
16
+ commitUpdateAnimationTarget(this.target, {
17
+ x: newX,
18
+ y: newY
19
+ }, {
15
20
  x: point.x,
16
21
  y: point.y
17
22
  }), animator.animate(this.target, {
@@ -37,8 +42,8 @@ export class AxisUpdate extends AComponentAnimate {
37
42
  onBind() {
38
43
  const animator = createComponentAnimator(this.target);
39
44
  this._animator = animator;
40
- const duration = this.duration, easing = this.easing, {config: config, diffAttrs: diffAttrs} = this.params;
41
- animator.animate(this.target, {
45
+ const duration = this.duration, easing = this.easing, {diffAttrs: diffAttrs} = this.params;
46
+ commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs)), animator.animate(this.target, {
42
47
  type: "to",
43
48
  to: Object.assign({}, diffAttrs),
44
49
  duration: duration,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/animation/axis-animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKxG,MAAM,OAAO,SAAU,SAAQ,iBAAsB;IACnD,MAAM;;QACJ,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAExD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAClC,IAAI,SAAS,IAAI,YAAY,IAAI,QAAQ,EAAE;YACzC,KAAK,GAAG,GAAG,CAAC;YAEZ,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpD,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YAErC,IAAI,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c,CAAC,GAAW;QACxB,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAGS,kBAAkB;QAC1B,OAAO;IACT,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB;IAEjC,eAAe,CAAC,sBAAsB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/D,eAAe,CAAC,sBAAsB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC","file":"axis-animate.js","sourcesContent":["import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from '@visactor/vrender-animate';\n\n/**\n * AxisEnter class handles the enter animation for Axis components\n */\nexport class AxisEnter extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, lastScale, getTickCoord } = this.params;\n\n let ratio = 1;\n const currData = this.target.data;\n if (lastScale && getTickCoord && currData) {\n ratio = 0.7;\n\n const oldValue = lastScale.scale(currData.rawValue);\n const point = getTickCoord(oldValue);\n const newX = this.target.attribute.x;\n const newY = this.target.attribute.y;\n\n this.target.setAttributes({ x: point.x, y: point.y });\n animator.animate(this.target, {\n type: 'to',\n to: { x: newX, y: newY },\n duration,\n easing\n });\n }\n\n // if (updateEls && updateEls.length > 1) {\n // ratio = 0.5;\n // const oldData1 = updateEls[0].oldEl.data;\n // const { rawValue: oldRawValue1, value: oldValue1 } = oldData1;\n // const oldData2 = updateEls[1].oldEl.data;\n // const { rawValue: oldRawValue2, value: oldValue2 } = oldData2;\n // const data = this.target.data;\n // const { rawValue: newRawValue } = data;\n // // rawValue 是原始值,value是映射出来的值,假设是线性映射,计算一下newRawValue在old阶段的value是什么值\n // const oldValue =\n // oldValue1 + ((oldValue2 - oldValue1) * (newRawValue - oldRawValue1)) / (oldRawValue2 - oldRawValue1);\n // // 将 x 和 y 做映射\n // const oldX1 = updateEls[0].oldEl.attribute.x;\n // const oldY1 = updateEls[0].oldEl.attribute.y;\n // const oldX2 = updateEls[1].oldEl.attribute.x;\n // const oldY2 = updateEls[1].oldEl.attribute.y;\n // const oldX = oldX1 + ((oldX2 - oldX1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const oldY = oldY1 + ((oldY2 - oldY1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const newX = this.target.attribute.x;\n // const newY = this.target.attribute.y;\n\n // this.target.setAttributes({ x: oldX, y: oldY });\n // animator.animate(this.target, {\n // type: 'to',\n // to: { x: newX, y: newY },\n // duration,\n // easing\n // });\n // }\n\n animator.animate(this.target, {\n type: config.type ?? 'fadeIn',\n to: config.to,\n duration: duration * ratio,\n easing\n });\n this.completeBind(animator);\n }\n}\n\n/**\n * AxisUpdate class handles the update animation for Axis components\n */\nexport class AxisUpdate extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, diffAttrs } = this.params;\n // this.target.applyAnimationState(\n // ['update'],\n // [\n // {\n // name: 'update',\n // animation: {\n // type: 'to',\n // to: { ...this.props },\n // duration,\n // easing,\n // customParameters: {\n // diffAttrs: { ...this.props }\n // }\n // }\n // }\n // ]\n // );\n // console.log('this.props', this.props, { ...this.target.attribute });\n animator.animate(this.target, {\n type: 'to',\n to: { ...diffAttrs },\n duration,\n easing,\n customParameters: {\n diffAttrs: { ...diffAttrs }\n }\n });\n this.completeBind(animator);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以当需要屏蔽自身属性时,需要通过animator中执行\n deleteSelfAttr(key: string): void {\n super.deleteSelfAttr(key);\n this._animator.deleteSelfAttr(key);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport function registerAxisAnimate() {\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('axisEn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AC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAGS,kBAAkB;QAC1B,OAAO;IACT,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB;IAEjC,eAAe,CAAC,sBAAsB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/D,eAAe,CAAC,sBAAsB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC","file":"axis-animate.js","sourcesContent":["import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from '@visactor/vrender-animate';\nimport { commitUpdateAnimationTarget } from './static-truth';\n\n/**\n * AxisEnter class handles the enter animation for Axis components\n */\nexport class AxisEnter extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, lastScale, getTickCoord } = this.params;\n\n let ratio = 1;\n const currData = this.target.data;\n if (lastScale && getTickCoord && currData) {\n ratio = 0.7;\n\n const oldValue = lastScale.scale(currData.rawValue);\n const point = getTickCoord(oldValue);\n const newX = this.target.attribute.x;\n const newY = this.target.attribute.y;\n\n commitUpdateAnimationTarget(this.target, { x: newX, y: newY }, { x: point.x, y: point.y });\n animator.animate(this.target, {\n type: 'to',\n to: { x: newX, y: newY },\n duration,\n easing\n });\n }\n\n // if (updateEls && updateEls.length > 1) {\n // ratio = 0.5;\n // const oldData1 = updateEls[0].oldEl.data;\n // const { rawValue: oldRawValue1, value: oldValue1 } = oldData1;\n // const oldData2 = updateEls[1].oldEl.data;\n // const { rawValue: oldRawValue2, value: oldValue2 } = oldData2;\n // const data = this.target.data;\n // const { rawValue: newRawValue } = data;\n // // rawValue 是原始值,value是映射出来的值,假设是线性映射,计算一下newRawValue在old阶段的value是什么值\n // const oldValue =\n // oldValue1 + ((oldValue2 - oldValue1) * (newRawValue - oldRawValue1)) / (oldRawValue2 - oldRawValue1);\n // // 将 x 和 y 做映射\n // const oldX1 = updateEls[0].oldEl.attribute.x;\n // const oldY1 = updateEls[0].oldEl.attribute.y;\n // const oldX2 = updateEls[1].oldEl.attribute.x;\n // const oldY2 = updateEls[1].oldEl.attribute.y;\n // const oldX = oldX1 + ((oldX2 - oldX1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const oldY = oldY1 + ((oldY2 - oldY1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const newX = this.target.attribute.x;\n // const newY = this.target.attribute.y;\n\n // this.target.setAttributes({ x: oldX, y: oldY });\n // animator.animate(this.target, {\n // type: 'to',\n // to: { x: newX, y: newY },\n // duration,\n // easing\n // });\n // }\n\n animator.animate(this.target, {\n type: config.type ?? 'fadeIn',\n to: config.to,\n duration: duration * ratio,\n easing\n });\n this.completeBind(animator);\n }\n}\n\n/**\n * AxisUpdate class handles the update animation for Axis components\n */\nexport class AxisUpdate extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { diffAttrs } = this.params;\n // this.target.applyAnimationState(\n // ['update'],\n // [\n // {\n // name: 'update',\n // animation: {\n // type: 'to',\n // to: { ...this.props },\n // duration,\n // easing,\n // customParameters: {\n // diffAttrs: { ...this.props }\n // }\n // }\n // }\n // ]\n // );\n // console.log('this.props', this.props, { ...this.target.attribute });\n commitUpdateAnimationTarget(this.target, { ...diffAttrs });\n animator.animate(this.target, {\n type: 'to',\n to: { ...diffAttrs },\n duration,\n easing,\n customParameters: {\n diffAttrs: { ...diffAttrs }\n }\n });\n this.completeBind(animator);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以当需要屏蔽自身属性时,需要通过animator中执行\n deleteSelfAttr(key: string): void {\n super.deleteSelfAttr(key);\n this._animator.deleteSelfAttr(key);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport function registerAxisAnimate() {\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('axisEnter', AxisEnter);\n AnimateExecutor.registerBuiltInAnimate('axisUpdate', AxisUpdate);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { type IGraphic } from '@visactor/vrender-core';
2
+ export declare function commitUpdateAnimationTarget(graphic?: IGraphic, targetAttrs?: Record<string, any>, startAttrs?: Record<string, any>): void;
@@ -0,0 +1,18 @@
1
+ import { AttributeUpdateType } from "@visactor/vrender-core";
2
+
3
+ import { cloneDeep } from "@visactor/vutils";
4
+
5
+ export function commitUpdateAnimationTarget(graphic, targetAttrs, startAttrs) {
6
+ var _a, _b, _c, _d;
7
+ if (!graphic || !targetAttrs) return;
8
+ const committedTargetAttrs = cloneDeep(targetAttrs), transientStartAttrs = cloneDeep(null != startAttrs ? startAttrs : graphic.attribute);
9
+ graphic.setAttributes(committedTargetAttrs);
10
+ const baseAttributes = graphic.baseAttributes;
11
+ baseAttributes && "object" == typeof baseAttributes && Object.keys(committedTargetAttrs).forEach((key => {
12
+ baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);
13
+ })), null === (_b = (_a = graphic).setFinalAttributes) || void 0 === _b || _b.call(_a, committedTargetAttrs),
14
+ null === (_d = (_c = graphic).setAttributesAndPreventAnimate) || void 0 === _d || _d.call(_c, transientStartAttrs, !1, {
15
+ type: AttributeUpdateType.ANIMATE_BIND
16
+ });
17
+ }
18
+ //# sourceMappingURL=static-truth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/animation/static-truth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAiB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,UAAU,2BAA2B,CACzC,OAAkB,EAClB,WAAiC,EACjC,UAAgC;;IAEhC,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE;QAC5B,OAAO;KACR;IAED,MAAM,oBAAoB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,SAAS,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvE,OAAO,CAAC,aAAa,CAAC,oBAA2B,CAAC,CAAC;IACnD,MAAM,cAAc,GAAI,OAAe,CAAC,cAAc,CAAC;IACvD,IAAI,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACxD,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9C,cAAc,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;KACJ;IACD,MAAA,MAAC,OAAe,EAAC,kBAAkB,mDAAG,oBAAoB,CAAC,CAAC;IAC5D,MAAA,MAAC,OAAe,EAAC,8BAA8B,mDAAG,mBAA0B,EAAE,KAAK,EAAE;QACnF,IAAI,EAAE,mBAAmB,CAAC,YAAY;KACvC,CAAC,CAAC;AACL,CAAC","file":"static-truth.js","sourcesContent":["import { AttributeUpdateType, type IGraphic } from '@visactor/vrender-core';\nimport { cloneDeep } from '@visactor/vutils';\n\nexport function commitUpdateAnimationTarget(\n graphic?: IGraphic,\n targetAttrs?: Record<string, any>,\n startAttrs?: Record<string, any>\n) {\n if (!graphic || !targetAttrs) {\n return;\n }\n\n const committedTargetAttrs = cloneDeep(targetAttrs);\n const transientStartAttrs = cloneDeep(startAttrs ?? graphic.attribute);\n\n graphic.setAttributes(committedTargetAttrs as any);\n const baseAttributes = (graphic as any).baseAttributes;\n if (baseAttributes && typeof baseAttributes === 'object') {\n Object.keys(committedTargetAttrs).forEach(key => {\n baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);\n });\n }\n (graphic as any).setFinalAttributes?.(committedTargetAttrs);\n (graphic as any).setAttributesAndPreventAnimate?.(transientStartAttrs as any, false, {\n type: AttributeUpdateType.ANIMATE_BIND\n });\n}\n"]}
@@ -1,9 +1,9 @@
1
- import { AnimateMode } from '@visactor/vrender-core';
2
- import type { IGroup } from '@visactor/vrender-core';
1
+ import { AnimateMode, type IGroup } from '@visactor/vrender-core';
3
2
  import { ACustomAnimate } from '@visactor/vrender-animate';
4
3
  export declare class GroupTransition extends ACustomAnimate<any> {
5
4
  target: IGroup;
6
5
  private _newElementAttrMap;
6
+ private _started;
7
7
  mode: AnimateMode;
8
8
  onBind(): void;
9
9
  onStart(): void;
@@ -6,11 +6,14 @@ import { cloneDeep, interpolateString, isEqual, isValidNumber } from "@visactor/
6
6
 
7
7
  import { traverseGroup } from "../../util";
8
8
 
9
+ import { commitUpdateAnimationTarget } from "../../animation/static-truth";
10
+
9
11
  export class GroupTransition extends ACustomAnimate {
10
12
  constructor() {
11
13
  super(...arguments), this.mode = AnimateMode.NORMAL;
12
14
  }
13
15
  onBind() {
16
+ this._started = !1;
14
17
  const currentInnerView = this.target.getInnerView(), prevInnerView = this.target.getPrevInnerView();
15
18
  prevInnerView && (this._newElementAttrMap = {}, traverseGroup(currentInnerView, (el => {
16
19
  var _a, _b, _c, _d, _e, _f;
@@ -27,7 +30,7 @@ export class GroupTransition extends ACustomAnimate {
27
30
  fillOpacity: null !== (_b = newProps.fillOpacity) && void 0 !== _b ? _b : 1,
28
31
  strokeOpacity: null !== (_c = newProps.strokeOpacity) && void 0 !== _c ? _c : 1
29
32
  })
30
- }, el.setAttributes(oldEl.attribute);
33
+ }, commitUpdateAnimationTarget(el, this._newElementAttrMap[el.id].attrs, cloneDeep(oldEl.attribute));
31
34
  }
32
35
  } else {
33
36
  const finalOpacityAttrs = {
@@ -39,7 +42,7 @@ export class GroupTransition extends ACustomAnimate {
39
42
  state: "enter",
40
43
  node: el,
41
44
  attrs: finalOpacityAttrs
42
- }, el.setAttributes({
45
+ }, commitUpdateAnimationTarget(el, finalOpacityAttrs, {
43
46
  opacity: 0,
44
47
  fillOpacity: 0,
45
48
  strokeOpacity: 0
@@ -49,6 +52,8 @@ export class GroupTransition extends ACustomAnimate {
49
52
  })));
50
53
  }
51
54
  onStart() {
55
+ if (this._started) return;
56
+ this._started = !0;
52
57
  let duration = this.duration, easing = this.easing;
53
58
  this._newElementAttrMap && Object.keys(this._newElementAttrMap).forEach((id => {
54
59
  var _a;