@visactor/vrender-core 1.1.0-alpha.6 → 1.1.0-alpha.7
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/cjs/common/diff.js +1 -2
- package/cjs/common/event-transformer.js +2 -1
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +1 -1
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -2
- package/cjs/common/simplify.js +1 -1
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/text.js +1 -1
- package/cjs/common/utils.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +2 -0
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +2 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.js +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/graphic/graphic.d.ts +4 -2
- package/cjs/graphic/graphic.js +30 -12
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/rect.d.ts +2 -0
- package/cjs/graphic/rect.js +44 -0
- package/cjs/graphic/rect.js.map +1 -1
- package/cjs/graphic/state/state-transition-orchestrator.d.ts +5 -0
- package/cjs/graphic/state/state-transition-orchestrator.js +17 -5
- package/cjs/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/dist/index.es.js +131 -21
- package/es/common/diff.js +1 -2
- package/es/common/event-transformer.js +2 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +1 -1
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -2
- package/es/common/simplify.js +1 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/store.js +1 -1
- package/es/common/text.js +1 -1
- package/es/common/utils.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +2 -0
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +2 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.js +1 -1
- package/es/core/window.js +1 -1
- package/es/graphic/graphic.d.ts +4 -2
- package/es/graphic/graphic.js +30 -12
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/rect.d.ts +2 -0
- package/es/graphic/rect.js +44 -0
- package/es/graphic/rect.js.map +1 -1
- package/es/graphic/state/state-transition-orchestrator.d.ts +5 -0
- package/es/graphic/state/state-transition-orchestrator.js +17 -5
- package/es/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/package.json +3 -3
package/es/core/light.js
CHANGED
package/es/core/stage.js
CHANGED
package/es/core/window.js
CHANGED
package/es/graphic/graphic.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/es/graphic/graphic.js
CHANGED
|
@@ -297,13 +297,21 @@ 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
|
-
|
|
301
|
-
const
|
|
302
|
-
if (!previousResolvedStatePatch) return
|
|
303
|
-
const snapshot = this.buildStaticAttributeSnapshot();
|
|
300
|
+
buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
|
|
301
|
+
const extraAttrs = {};
|
|
302
|
+
if (!previousResolvedStatePatch) return extraAttrs;
|
|
303
|
+
const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
|
|
304
304
|
return Object.keys(previousResolvedStatePatch).forEach((key => {
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
|
|
306
|
+
if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
|
|
307
|
+
const assignFallbackAttr = value => {
|
|
308
|
+
void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
|
|
309
|
+
};
|
|
310
|
+
if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs)); else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
|
|
311
|
+
const snapshotValue = snapshot[key];
|
|
312
|
+
assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
|
|
313
|
+
} else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
|
|
314
|
+
})), extraAttrs;
|
|
307
315
|
}
|
|
308
316
|
syncObjectToSnapshot(target, snapshot) {
|
|
309
317
|
const delta = new Map;
|
|
@@ -724,20 +732,30 @@ export class Graphic extends Node {
|
|
|
724
732
|
var _a, _b, _c;
|
|
725
733
|
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;
|
|
726
734
|
}
|
|
727
|
-
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
|
|
735
|
+
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
|
|
728
736
|
const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
|
|
729
|
-
animateConfig: resolvedAnimateConfig
|
|
737
|
+
animateConfig: resolvedAnimateConfig,
|
|
738
|
+
extraAnimateAttrs: extraAnimateAttrs,
|
|
739
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
|
|
730
740
|
} : void 0;
|
|
731
741
|
if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
|
|
732
742
|
const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
|
|
733
743
|
noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
|
|
734
|
-
animateConfig: resolvedAnimateConfig
|
|
744
|
+
animateConfig: resolvedAnimateConfig,
|
|
745
|
+
extraAnimateAttrs: extraAnimateAttrs,
|
|
746
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
|
|
735
747
|
});
|
|
736
748
|
this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
|
|
737
749
|
}
|
|
738
750
|
updateNormalAttrs(stateAttrs) {
|
|
739
751
|
this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
|
|
740
752
|
}
|
|
753
|
+
getStateTransitionDefaultAttribute(key, targetAttrs) {
|
|
754
|
+
return this.getDefaultAttribute(key);
|
|
755
|
+
}
|
|
756
|
+
shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
|
|
757
|
+
return !1;
|
|
758
|
+
}
|
|
741
759
|
stopStateAnimates(type = "end") {
|
|
742
760
|
const stopAnimationState = this.stopAnimationState;
|
|
743
761
|
if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
|
|
@@ -753,7 +771,7 @@ export class Graphic extends Node {
|
|
|
753
771
|
}
|
|
754
772
|
clearStates(hasAnimation) {
|
|
755
773
|
var _a, _b, _c;
|
|
756
|
-
const previousStates = this.currentStates ? this.currentStates.slice() : [], transition = this.createStateModel().clearStates();
|
|
774
|
+
const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
|
|
757
775
|
if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
|
|
758
776
|
this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
|
|
759
777
|
void this.clearSharedStateActiveRegistrations();
|
|
@@ -764,7 +782,7 @@ export class Graphic extends Node {
|
|
|
764
782
|
null === (_c = getStageStatePerfMonitor(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
|
|
765
783
|
graphicId: this._uid,
|
|
766
784
|
targetStates: []
|
|
767
|
-
}), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0)) : (this.stopStateAnimates(),
|
|
785
|
+
}), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
768
786
|
this._restoreAttributeFromStaticTruth({
|
|
769
787
|
type: AttributeUpdateType.STATE
|
|
770
788
|
}), this._emitCustomEvent("afterStateUpdate", {
|
|
@@ -797,7 +815,7 @@ export class Graphic extends Node {
|
|
|
797
815
|
null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
|
|
798
816
|
graphicId: this._uid,
|
|
799
817
|
targetStates: [ ...transition.states ]
|
|
800
|
-
}), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(
|
|
818
|
+
}), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
801
819
|
this._restoreAttributeFromStaticTruth({
|
|
802
820
|
type: AttributeUpdateType.STATE
|
|
803
821
|
}), this._emitCustomEvent("afterStateUpdate", {
|