@visactor/vrender-core 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.
@@ -149,7 +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
+ protected buildRemovedStateAnimationAttrs(targetStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>): Partial<T>;
153
153
  protected syncObjectToSnapshot(target: Record<string, any>, snapshot: Record<string, any>): AttributeDelta;
154
154
  protected _syncAttribute(): AttributeDelta;
155
155
  protected _syncFinalAttributeFromStaticTruth(): void;
@@ -211,8 +211,10 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
211
211
  getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
212
212
  protected createStateModel(): StateModel<T>;
213
213
  protected resolveStateAnimateConfig(animateConfig?: IAnimateConfig): any;
214
- applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig): void;
214
+ applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig, extraAnimateAttrs?: Partial<T>): void;
215
215
  updateNormalAttrs(stateAttrs: Partial<T>): void;
216
+ protected getStateTransitionDefaultAttribute(key: string, targetAttrs?: Partial<T>): any;
217
+ protected shouldSkipStateTransitionDefaultAttribute(_key: string, _targetAttrs?: Partial<T>): boolean;
216
218
  protected stopStateAnimates(type?: 'start' | 'end'): void;
217
219
  private getNormalAttribute;
218
220
  clearStates(hasAnimation?: boolean): void;
@@ -254,13 +254,21 @@ class Graphic extends node_tree_1.Node {
254
254
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
255
255
  })), snapshot) : snapshot;
256
256
  }
257
- buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
258
- const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
259
- if (!previousResolvedStatePatch) return targetAttrs;
260
- const snapshot = this.buildStaticAttributeSnapshot();
257
+ buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
258
+ const extraAttrs = {};
259
+ if (!previousResolvedStatePatch) return extraAttrs;
260
+ const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
261
261
  return Object.keys(previousResolvedStatePatch).forEach((key => {
262
- Object.prototype.hasOwnProperty.call(targetAttrs, key) || (targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key) ? cloneAttributeValue(snapshot[key]) : this.getDefaultAttribute(key));
263
- })), targetAttrs;
262
+ const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
263
+ if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
264
+ const assignFallbackAttr = value => {
265
+ void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
266
+ };
267
+ if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs)); else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
268
+ const snapshotValue = snapshot[key];
269
+ assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
270
+ } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
271
+ })), extraAttrs;
264
272
  }
265
273
  syncObjectToSnapshot(target, snapshot) {
266
274
  const delta = new Map;
@@ -689,20 +697,30 @@ class Graphic extends node_tree_1.Node {
689
697
  var _a, _b, _c;
690
698
  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 : config_2.DefaultStateAnimateConfig;
691
699
  }
692
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
700
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
693
701
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
694
- animateConfig: resolvedAnimateConfig
702
+ animateConfig: resolvedAnimateConfig,
703
+ extraAnimateAttrs: extraAnimateAttrs,
704
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
695
705
  } : void 0;
696
706
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
697
707
  const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
698
708
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
699
- animateConfig: resolvedAnimateConfig
709
+ animateConfig: resolvedAnimateConfig,
710
+ extraAnimateAttrs: extraAnimateAttrs,
711
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
700
712
  });
701
713
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
702
714
  }
703
715
  updateNormalAttrs(stateAttrs) {
704
716
  this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
705
717
  }
718
+ getStateTransitionDefaultAttribute(key, targetAttrs) {
719
+ return this.getDefaultAttribute(key);
720
+ }
721
+ shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
722
+ return !1;
723
+ }
706
724
  stopStateAnimates(type = "end") {
707
725
  const stopAnimationState = this.stopAnimationState;
708
726
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
@@ -718,7 +736,7 @@ class Graphic extends node_tree_1.Node {
718
736
  }
719
737
  clearStates(hasAnimation) {
720
738
  var _a, _b, _c;
721
- const previousStates = this.currentStates ? this.currentStates.slice() : [], transition = this.createStateModel().clearStates();
739
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
722
740
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
723
741
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
724
742
  void this.clearSharedStateActiveRegistrations();
@@ -729,7 +747,7 @@ class Graphic extends node_tree_1.Node {
729
747
  null === (_c = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
730
748
  graphicId: this._uid,
731
749
  targetStates: []
732
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0)) : (this.stopStateAnimates(),
750
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
733
751
  this._restoreAttributeFromStaticTruth({
734
752
  type: enums_1.AttributeUpdateType.STATE
735
753
  }), this._emitCustomEvent("afterStateUpdate", {
@@ -763,7 +781,7 @@ class Graphic extends node_tree_1.Node {
763
781
  null === (_e = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
764
782
  graphicId: this._uid,
765
783
  targetStates: [ ...transition.states ]
766
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation)) : (this.stopStateAnimates(),
784
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
767
785
  this._restoreAttributeFromStaticTruth({
768
786
  type: enums_1.AttributeUpdateType.STATE
769
787
  }), this._emitCustomEvent("afterStateUpdate", {