@visactor/vrender-core 1.1.0-alpha.5 → 1.1.0-alpha.6

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/dist/index.es.js CHANGED
@@ -10859,6 +10859,22 @@ class Graphic extends Node {
10859
10859
  });
10860
10860
  return snapshot;
10861
10861
  }
10862
+ buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
10863
+ const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
10864
+ if (!previousResolvedStatePatch) {
10865
+ return targetAttrs;
10866
+ }
10867
+ const snapshot = this.buildStaticAttributeSnapshot();
10868
+ Object.keys(previousResolvedStatePatch).forEach(key => {
10869
+ if (Object.prototype.hasOwnProperty.call(targetAttrs, key)) {
10870
+ return;
10871
+ }
10872
+ targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key)
10873
+ ? cloneAttributeValue(snapshot[key])
10874
+ : this.getDefaultAttribute(key);
10875
+ });
10876
+ return targetAttrs;
10877
+ }
10862
10878
  syncObjectToSnapshot(target, snapshot) {
10863
10879
  const delta = new Map();
10864
10880
  const keySet = new Set([...Object.keys(target), ...Object.keys(snapshot)]);
@@ -11668,6 +11684,9 @@ class Graphic extends Node {
11668
11684
  return;
11669
11685
  }
11670
11686
  const previousStates = this.currentStates ? this.currentStates.slice() : [];
11687
+ const previousResolvedStatePatch = this.resolvedStatePatch
11688
+ ? cloneAttributeValue(this.resolvedStatePatch)
11689
+ : undefined;
11671
11690
  const stateResolveBaseAttrs = ((_a = this.baseAttributes) !== null && _a !== void 0 ? _a : this.attribute);
11672
11691
  const stateModel = this.createStateModel();
11673
11692
  (_b = this.stateEngine) === null || _b === void 0 ? void 0 : _b.setResolveContext(this, stateResolveBaseAttrs);
@@ -11693,7 +11712,7 @@ class Graphic extends Node {
11693
11712
  });
11694
11713
  if (hasAnimation) {
11695
11714
  this._syncFinalAttributeFromStaticTruth();
11696
- this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation);
11715
+ this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation);
11697
11716
  }
11698
11717
  else {
11699
11718
  this.stopStateAnimates();
@@ -1,4 +1,3 @@
1
1
  export const CanvasFactory = Symbol.for("CanvasFactory");
2
2
 
3
- export const Context2dFactory = Symbol.for("Context2dFactory");
4
- //# sourceMappingURL=constants.js.map
3
+ export const Context2dFactory = Symbol.for("Context2dFactory");
@@ -2,4 +2,5 @@ export * from "./interpolate";
2
2
 
3
3
  export * from "./store";
4
4
 
5
- export * from "./colorName";
5
+ export * from "./colorName";
6
+ //# sourceMappingURL=index.js.map
@@ -149,6 +149,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
149
149
  };
150
150
  protected recomputeCurrentStatePatch(): void;
151
151
  protected buildStaticAttributeSnapshot(): Partial<T>;
152
+ protected buildStateAnimationTargetAttrs(resolvedStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>): Partial<T>;
152
153
  protected syncObjectToSnapshot(target: Record<string, any>, snapshot: Record<string, any>): AttributeDelta;
153
154
  protected _syncAttribute(): AttributeDelta;
154
155
  protected _syncFinalAttributeFromStaticTruth(): void;
@@ -297,6 +297,14 @@ export class Graphic extends Node {
297
297
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
298
298
  })), snapshot) : snapshot;
299
299
  }
300
+ buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
301
+ const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
302
+ if (!previousResolvedStatePatch) return targetAttrs;
303
+ const snapshot = this.buildStaticAttributeSnapshot();
304
+ return Object.keys(previousResolvedStatePatch).forEach((key => {
305
+ Object.prototype.hasOwnProperty.call(targetAttrs, key) || (targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key) ? cloneAttributeValue(snapshot[key]) : this.getDefaultAttribute(key));
306
+ })), targetAttrs;
307
+ }
300
308
  syncObjectToSnapshot(target, snapshot) {
301
309
  const delta = new Map;
302
310
  return new Set([ ...Object.keys(target), ...Object.keys(snapshot) ]).forEach((key => {
@@ -778,7 +786,7 @@ export class Graphic extends Node {
778
786
  useStates(states, hasAnimation) {
779
787
  var _a, _b, _c, _d, _e;
780
788
  if (!states.length) return void this.clearStates(hasAnimation);
781
- const previousStates = this.currentStates ? this.currentStates.slice() : [], stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
789
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
782
790
  null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
783
791
  const transition = stateModel.useStates(states);
784
792
  if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
@@ -789,7 +797,7 @@ export class Graphic extends Node {
789
797
  null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
790
798
  graphicId: this._uid,
791
799
  targetStates: [ ...transition.states ]
792
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation)) : (this.stopStateAnimates(),
800
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation)) : (this.stopStateAnimates(),
793
801
  this._restoreAttributeFromStaticTruth({
794
802
  type: AttributeUpdateType.STATE
795
803
  }), this._emitCustomEvent("afterStateUpdate", {