@visactor/vrender-animate 0.22.4
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/README.md +177 -0
- package/cjs/animate-extension.d.ts +15 -0
- package/cjs/animate-extension.js +46 -0
- package/cjs/animate-extension.js.map +1 -0
- package/cjs/animate.d.ts +71 -0
- package/cjs/animate.js +210 -0
- package/cjs/animate.js.map +1 -0
- package/cjs/custom/clip-graphic.d.ts +53 -0
- package/cjs/custom/clip-graphic.js +146 -0
- package/cjs/custom/clip-graphic.js.map +1 -0
- package/cjs/custom/clip.d.ts +13 -0
- package/cjs/custom/clip.js +24 -0
- package/cjs/custom/clip.js.map +1 -0
- package/cjs/custom/common.d.ts +22 -0
- package/cjs/custom/common.js +58 -0
- package/cjs/custom/common.js.map +1 -0
- package/cjs/custom/custom-animate.d.ts +15 -0
- package/cjs/custom/custom-animate.js +25 -0
- package/cjs/custom/custom-animate.js.map +1 -0
- package/cjs/custom/fade.d.ts +13 -0
- package/cjs/custom/fade.js +24 -0
- package/cjs/custom/fade.js.map +1 -0
- package/cjs/custom/group-fade.d.ts +16 -0
- package/cjs/custom/group-fade.js +66 -0
- package/cjs/custom/group-fade.js.map +1 -0
- package/cjs/custom/growAngle.d.ts +37 -0
- package/cjs/custom/growAngle.js +140 -0
- package/cjs/custom/growAngle.js.map +1 -0
- package/cjs/custom/growCenter.d.ts +17 -0
- package/cjs/custom/growCenter.js +161 -0
- package/cjs/custom/growCenter.js.map +1 -0
- package/cjs/custom/growHeight.d.ts +36 -0
- package/cjs/custom/growHeight.js +154 -0
- package/cjs/custom/growHeight.js.map +1 -0
- package/cjs/custom/growPoints.d.ts +52 -0
- package/cjs/custom/growPoints.js +227 -0
- package/cjs/custom/growPoints.js.map +1 -0
- package/cjs/custom/growRadius.d.ts +41 -0
- package/cjs/custom/growRadius.js +113 -0
- package/cjs/custom/growRadius.js.map +1 -0
- package/cjs/custom/growWidth.d.ts +36 -0
- package/cjs/custom/growWidth.js +154 -0
- package/cjs/custom/growWidth.js.map +1 -0
- package/cjs/custom/input-text.d.ts +29 -0
- package/cjs/custom/input-text.js +45 -0
- package/cjs/custom/input-text.js.map +1 -0
- package/cjs/custom/number.d.ts +25 -0
- package/cjs/custom/number.js +102 -0
- package/cjs/custom/number.js.map +1 -0
- package/cjs/custom/register.d.ts +1 -0
- package/cjs/custom/register.js +35 -0
- package/cjs/custom/register.js.map +1 -0
- package/cjs/custom/scale-in.d.ts +13 -0
- package/cjs/custom/scale-in.js +57 -0
- package/cjs/custom/scale-in.js.map +1 -0
- package/cjs/custom/scale.d.ts +20 -0
- package/cjs/custom/scale.js +106 -0
- package/cjs/custom/scale.js.map +1 -0
- package/cjs/custom/sphere.d.ts +20 -0
- package/cjs/custom/sphere.js +26 -0
- package/cjs/custom/sphere.js.map +1 -0
- package/cjs/custom/state.d.ts +13 -0
- package/cjs/custom/state.js +25 -0
- package/cjs/custom/state.js.map +1 -0
- package/cjs/custom/tag-points.d.ts +26 -0
- package/cjs/custom/tag-points.js +81 -0
- package/cjs/custom/tag-points.js.map +1 -0
- package/cjs/custom/update.d.ts +14 -0
- package/cjs/custom/update.js +26 -0
- package/cjs/custom/update.js.map +1 -0
- package/cjs/executor/animate-executor.d.ts +36 -0
- package/cjs/executor/animate-executor.js +177 -0
- package/cjs/executor/animate-executor.js.map +1 -0
- package/cjs/executor/executor.d.ts +69 -0
- package/cjs/executor/executor.js +6 -0
- package/cjs/executor/executor.js.map +1 -0
- package/cjs/index.d.ts +25 -0
- package/cjs/index.js +214 -0
- package/cjs/index.js.map +1 -0
- package/cjs/interpolate/executor.d.ts +66 -0
- package/cjs/interpolate/executor.js +6 -0
- package/cjs/interpolate/executor.js.map +1 -0
- package/cjs/interpolate/number.d.ts +1 -0
- package/cjs/interpolate/number.js +10 -0
- package/cjs/interpolate/number.js.map +1 -0
- package/cjs/interpolate/store.d.ts +32 -0
- package/cjs/interpolate/store.js +96 -0
- package/cjs/interpolate/store.js.map +1 -0
- package/cjs/intreface/animate.d.ts +91 -0
- package/cjs/intreface/animate.js +10 -0
- package/cjs/intreface/animate.js.map +1 -0
- package/cjs/intreface/easing.d.ts +3 -0
- package/cjs/intreface/easing.js +6 -0
- package/cjs/intreface/easing.js.map +1 -0
- package/cjs/intreface/state.d.ts +35 -0
- package/cjs/intreface/state.js +6 -0
- package/cjs/intreface/state.js.map +1 -0
- package/cjs/intreface/ticker.d.ts +37 -0
- package/cjs/intreface/ticker.js +10 -0
- package/cjs/intreface/ticker.js.map +1 -0
- package/cjs/intreface/timeline.d.ts +17 -0
- package/cjs/intreface/timeline.js +6 -0
- package/cjs/intreface/timeline.js.map +1 -0
- package/cjs/intreface/type.d.ts +13 -0
- package/cjs/intreface/type.js +15 -0
- package/cjs/intreface/type.js.map +1 -0
- package/cjs/register.d.ts +1 -0
- package/cjs/register.js +19 -0
- package/cjs/register.js.map +1 -0
- package/cjs/state/animation-state-machine.d.ts +22 -0
- package/cjs/state/animation-state-machine.js +53 -0
- package/cjs/state/animation-state-machine.js.map +1 -0
- package/cjs/state/animation-state-queue.d.ts +24 -0
- package/cjs/state/animation-state-queue.js +66 -0
- package/cjs/state/animation-state-queue.js.map +1 -0
- package/cjs/state/animation-state-registry.d.ts +14 -0
- package/cjs/state/animation-state-registry.js +53 -0
- package/cjs/state/animation-state-registry.js.map +1 -0
- package/cjs/state/animation-state.d.ts +25 -0
- package/cjs/state/animation-state.js +80 -0
- package/cjs/state/animation-state.js.map +1 -0
- package/cjs/state/animation-states-registry.d.ts +17 -0
- package/cjs/state/animation-states-registry.js +95 -0
- package/cjs/state/animation-states-registry.js.map +1 -0
- package/cjs/state/graphic-extension.d.ts +12 -0
- package/cjs/state/graphic-extension.js +37 -0
- package/cjs/state/graphic-extension.js.map +1 -0
- package/cjs/state/index.d.ts +3 -0
- package/cjs/state/index.js +22 -0
- package/cjs/state/index.js.map +1 -0
- package/cjs/state/types.d.ts +11 -0
- package/cjs/state/types.js +6 -0
- package/cjs/state/types.js.map +1 -0
- package/cjs/step.d.ts +49 -0
- package/cjs/step.js +124 -0
- package/cjs/step.js.map +1 -0
- package/cjs/ticker/default-ticker.d.ts +39 -0
- package/cjs/ticker/default-ticker.js +133 -0
- package/cjs/ticker/default-ticker.js.map +1 -0
- package/cjs/ticker/manual-ticker.d.ts +6 -0
- package/cjs/ticker/manual-ticker.js +37 -0
- package/cjs/ticker/manual-ticker.js.map +1 -0
- package/cjs/timeline.d.ts +34 -0
- package/cjs/timeline.js +84 -0
- package/cjs/timeline.js.map +1 -0
- package/cjs/utils/easing-func.d.ts +1 -0
- package/cjs/utils/easing-func.js +16 -0
- package/cjs/utils/easing-func.js.map +1 -0
- package/cjs/utils/easing.d.ts +49 -0
- package/cjs/utils/easing.js +141 -0
- package/cjs/utils/easing.js.map +1 -0
- package/dist/index.es.js +3824 -0
- package/es/animate-extension.d.ts +15 -0
- package/es/animate-extension.js +42 -0
- package/es/animate-extension.js.map +1 -0
- package/es/animate.d.ts +71 -0
- package/es/animate.js +207 -0
- package/es/animate.js.map +1 -0
- package/es/custom/clip-graphic.d.ts +53 -0
- package/es/custom/clip-graphic.js +134 -0
- package/es/custom/clip-graphic.js.map +1 -0
- package/es/custom/clip.d.ts +13 -0
- package/es/custom/clip.js +14 -0
- package/es/custom/clip.js.map +1 -0
- package/es/custom/common.d.ts +22 -0
- package/es/custom/common.js +48 -0
- package/es/custom/common.js.map +1 -0
- package/es/custom/custom-animate.d.ts +15 -0
- package/es/custom/custom-animate.js +17 -0
- package/es/custom/custom-animate.js.map +1 -0
- package/es/custom/fade.d.ts +13 -0
- package/es/custom/fade.js +14 -0
- package/es/custom/fade.js.map +1 -0
- package/es/custom/group-fade.d.ts +16 -0
- package/es/custom/group-fade.js +56 -0
- package/es/custom/group-fade.js.map +1 -0
- package/es/custom/growAngle.d.ts +37 -0
- package/es/custom/growAngle.js +132 -0
- package/es/custom/growAngle.js.map +1 -0
- package/es/custom/growCenter.d.ts +17 -0
- package/es/custom/growCenter.js +155 -0
- package/es/custom/growCenter.js.map +1 -0
- package/es/custom/growHeight.d.ts +36 -0
- package/es/custom/growHeight.js +144 -0
- package/es/custom/growHeight.js.map +1 -0
- package/es/custom/growPoints.d.ts +52 -0
- package/es/custom/growPoints.js +219 -0
- package/es/custom/growPoints.js.map +1 -0
- package/es/custom/growRadius.d.ts +41 -0
- package/es/custom/growRadius.js +105 -0
- package/es/custom/growRadius.js.map +1 -0
- package/es/custom/growWidth.d.ts +36 -0
- package/es/custom/growWidth.js +144 -0
- package/es/custom/growWidth.js.map +1 -0
- package/es/custom/input-text.d.ts +29 -0
- package/es/custom/input-text.js +37 -0
- package/es/custom/input-text.js.map +1 -0
- package/es/custom/number.d.ts +25 -0
- package/es/custom/number.js +94 -0
- package/es/custom/number.js.map +1 -0
- package/es/custom/register.d.ts +1 -0
- package/es/custom/register.js +39 -0
- package/es/custom/register.js.map +1 -0
- package/es/custom/scale-in.d.ts +13 -0
- package/es/custom/scale-in.js +49 -0
- package/es/custom/scale-in.js.map +1 -0
- package/es/custom/scale.d.ts +20 -0
- package/es/custom/scale.js +96 -0
- package/es/custom/scale.js.map +1 -0
- package/es/custom/sphere.d.ts +20 -0
- package/es/custom/sphere.js +20 -0
- package/es/custom/sphere.js.map +1 -0
- package/es/custom/state.d.ts +13 -0
- package/es/custom/state.js +17 -0
- package/es/custom/state.js.map +1 -0
- package/es/custom/tag-points.d.ts +26 -0
- package/es/custom/tag-points.js +77 -0
- package/es/custom/tag-points.js.map +1 -0
- package/es/custom/update.d.ts +14 -0
- package/es/custom/update.js +18 -0
- package/es/custom/update.js.map +1 -0
- package/es/executor/animate-executor.d.ts +36 -0
- package/es/executor/animate-executor.js +169 -0
- package/es/executor/animate-executor.js.map +1 -0
- package/es/executor/executor.d.ts +69 -0
- package/es/executor/executor.js +2 -0
- package/es/executor/executor.js.map +1 -0
- package/es/index.d.ts +25 -0
- package/es/index.js +50 -0
- package/es/index.js.map +1 -0
- package/es/interpolate/executor.d.ts +66 -0
- package/es/interpolate/executor.js +2 -0
- package/es/interpolate/executor.js.map +1 -0
- package/es/interpolate/number.d.ts +1 -0
- package/es/interpolate/number.js +4 -0
- package/es/interpolate/number.js.map +1 -0
- package/es/interpolate/store.d.ts +32 -0
- package/es/interpolate/store.js +88 -0
- package/es/interpolate/store.js.map +1 -0
- package/es/intreface/animate.d.ts +91 -0
- package/es/intreface/animate.js +6 -0
- package/es/intreface/animate.js.map +1 -0
- package/es/intreface/easing.d.ts +3 -0
- package/es/intreface/easing.js +2 -0
- package/es/intreface/easing.js.map +1 -0
- package/es/intreface/state.d.ts +35 -0
- package/es/intreface/state.js +2 -0
- package/es/intreface/state.js.map +1 -0
- package/es/intreface/ticker.d.ts +37 -0
- package/es/intreface/ticker.js +6 -0
- package/es/intreface/ticker.js.map +1 -0
- package/es/intreface/timeline.d.ts +17 -0
- package/es/intreface/timeline.js +2 -0
- package/es/intreface/timeline.js.map +1 -0
- package/es/intreface/type.d.ts +13 -0
- package/es/intreface/type.js +14 -0
- package/es/intreface/type.js.map +1 -0
- package/es/register.d.ts +1 -0
- package/es/register.js +20 -0
- package/es/register.js.map +1 -0
- package/es/state/animation-state-machine.d.ts +22 -0
- package/es/state/animation-state-machine.js +47 -0
- package/es/state/animation-state-machine.js.map +1 -0
- package/es/state/animation-state-queue.d.ts +24 -0
- package/es/state/animation-state-queue.js +58 -0
- package/es/state/animation-state-queue.js.map +1 -0
- package/es/state/animation-state-registry.d.ts +14 -0
- package/es/state/animation-state-registry.js +45 -0
- package/es/state/animation-state-registry.js.map +1 -0
- package/es/state/animation-state.d.ts +25 -0
- package/es/state/animation-state.js +72 -0
- package/es/state/animation-state.js.map +1 -0
- package/es/state/animation-states-registry.d.ts +17 -0
- package/es/state/animation-states-registry.js +87 -0
- package/es/state/animation-states-registry.js.map +1 -0
- package/es/state/graphic-extension.d.ts +12 -0
- package/es/state/graphic-extension.js +29 -0
- package/es/state/graphic-extension.js.map +1 -0
- package/es/state/index.d.ts +3 -0
- package/es/state/index.js +6 -0
- package/es/state/index.js.map +1 -0
- package/es/state/types.d.ts +11 -0
- package/es/state/types.js +2 -0
- package/es/state/types.js.map +1 -0
- package/es/step.d.ts +49 -0
- package/es/step.js +120 -0
- package/es/step.js.map +1 -0
- package/es/ticker/default-ticker.d.ts +39 -0
- package/es/ticker/default-ticker.js +129 -0
- package/es/ticker/default-ticker.js.map +1 -0
- package/es/ticker/manual-ticker.d.ts +6 -0
- package/es/ticker/manual-ticker.js +29 -0
- package/es/ticker/manual-ticker.js.map +1 -0
- package/es/timeline.d.ts +34 -0
- package/es/timeline.js +79 -0
- package/es/timeline.js.map +1 -0
- package/es/utils/easing-func.d.ts +1 -0
- package/es/utils/easing-func.js +8 -0
- package/es/utils/easing-func.js.map +1 -0
- package/es/utils/easing.d.ts +49 -0
- package/es/utils/easing.js +134 -0
- package/es/utils/easing.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/animation-state-queue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,MAAM,OAAO,mBAAmB;IAM9B,YACU,MAAyB,EACzB,QAAgC,EAChC,QAAyB,EACzB,aAA2G;QAH3G,WAAM,GAAN,MAAM,CAAmB;QACzB,aAAQ,GAAR,QAAQ,CAAwB;QAChC,aAAQ,GAAR,QAAQ,CAAiB;QACzB,kBAAa,GAAb,aAAa,CAA8F;QAT7G,UAAK,GAAa,EAAE,CAAC;QACrB,gBAAW,GAAkB,IAAI,CAAC;QAClC,oBAAe,GAAoB,IAAI,CAAC;QACxC,oBAAe,GAAY,KAAK,CAAC;IAOtC,CAAC;IAKJ,OAAO,CAAC,MAAyB;QAC/B,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;YAEnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACxB;SACF;aAAM;Y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roup } from '@visactor/vrender-core';\nimport type { IAnimate } from '../intreface/animate';\nimport type { IAnimationStateQueue } from '../intreface/state';\nimport type { AnimationStateRegistry } from './animation-state-registry';\nimport type { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n/**\n * Queue for managing sequential animation states\n */\nexport class AnimationStateQueue implements IAnimationStateQueue {\n private queue: string[] = [];\n private activeState: string | null = null;\n private activeAnimation: IAnimate | null = null;\n private processingQueue: boolean = false;\n\n constructor(\n private target: IGraphic | IGroup,\n private registry: AnimationStateRegistry,\n private executor: AnimateExecutor,\n private onStateChange: (event: 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject', state: string) => void\n ) {}\n\n /**\n * Add state(s) to queue\n */\n enqueue(states: string | string[]): void {\n if (isArray(states)) {\n // For array of states, add them to the queue in sequence\n for (const state of states) {\n this.queue.push(state);\n }\n } else {\n this.queue.push(states);\n }\n\n // If not already processing, start processing the queue\n if (!this.processingQueue) {\n this.processNextState();\n }\n }\n\n /**\n * Process the next state in queue\n */\n processNextState(): void {\n if (this.queue.length === 0 || this.processingQueue) {\n return;\n }\n\n this.processingQueue = true;\n const nextState = this.queue[0];\n\n // Check if we can apply this state now\n if (this.canApplyState(nextState)) {\n // Remove the state from the queue\n this.queue.shift();\n\n // If there's an active state that conflicts, we need to handle it\n if (this.activeState && this.registry.hasConflict(this.activeState, nextState)) {\n // Check if new state can interrupt current state\n if (this.registry.canInterrupt(this.activeState, nextState)) {\n // Interrupt current animation\n this.interruptCurrentState();\n this.applyState(nextState);\n } else {\n // Cannot interrupt, reject the state\n this.onStateChange('stateReject', nextState);\n this.processingQueue = false;\n this.processNextState(); // Continue with the next state\n }\n } else {\n // No conflict, apply the state\n this.applyState(nextState);\n }\n } else {\n // Cannot apply this state right now, reject it\n this.queue.shift();\n this.onStateChange('stateReject', nextState);\n this.processingQueue = false;\n this.processNextState(); // Continue with the next state\n }\n }\n\n /**\n * Apply a state animation\n */\n private applyState(state: string): void {\n const stateConfig = this.registry.getState(state);\n if (!stateConfig) {\n console.warn(`Animation state \"${state}\" not found`);\n this.processingQueue = false;\n this.processNextState();\n return;\n }\n\n this.activeState = state;\n this.onStateChange('stateStart', state);\n\n // Create and execute the animation\n this.activeAnimation = this.executor.executeItem(stateConfig.animation, this.target);\n\n // Register completion callback\n if (this.activeAnimation) {\n this.activeAnimation.onEnd(() => {\n this.onAnimationComplete();\n });\n } else {\n // If no animation was created, consider it completed immediately\n this.onAnimationComplete();\n }\n }\n\n /**\n * Called when current animation completes\n */\n onAnimationComplete(): void {\n if (this.activeState) {\n const completedState = this.activeState;\n this.onStateChange('stateEnd', completedState);\n\n // Apply transition delay if configured\n const transitionDelay = this.registry.getTransitionDelay(completedState);\n\n this.activeState = null;\n this.activeAnimation = null;\n this.processingQueue = false;\n\n if (transitionDelay > 0) {\n // Wait before processing next state\n setTimeout(() => {\n this.processNextState();\n }, transitionDelay);\n } else {\n // Process next state immediately\n this.processNextState();\n }\n }\n }\n\n /**\n * Interrupt the current state animation\n */\n private interruptCurrentState(): void {\n if (this.activeState && this.activeAnimation) {\n this.onStateChange('stateInterrupt', this.activeState);\n this.activeAnimation.stop('end'); // Stop at end state to avoid visual jumps\n this.activeAnimation = null;\n this.activeState = null;\n }\n }\n\n /**\n * Cancel current state and clear queue\n */\n cancel(): void {\n // Interrupt current animation if any\n this.interruptCurrentState();\n\n // Clear the queue\n this.queue = [];\n this.processingQueue = false;\n }\n\n /**\n * Check if we can apply a specific state now\n */\n canApplyState(state: string): boolean {\n // Check if the state is registered\n const stateConfig = this.registry.getState(state);\n if (!stateConfig) {\n return false;\n }\n\n // If there's no active state, we can apply\n if (!this.activeState) {\n return true;\n }\n\n // Check if there's a conflict and if we can resolve it\n if (this.registry.hasConflict(this.activeState, state)) {\n return this.registry.canInterrupt(this.activeState, state);\n }\n\n // No conflict, we can apply\n return true;\n }\n\n /**\n * Get the currently active state\n */\n getActiveState(): string | null {\n return this.activeState;\n }\n\n /**\n * Get the pending states in the queue\n */\n getPendingStates(): string[] {\n return [...this.queue];\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IAnimationStateConfig, IAnimationStateRegistry, IAnimationStateRule } from '../intreface/state';
|
|
2
|
+
export declare class AnimationStateRegistry implements IAnimationStateRegistry {
|
|
3
|
+
private states;
|
|
4
|
+
private rules;
|
|
5
|
+
register(state: IAnimationStateConfig, rule?: IAnimationStateRule): void;
|
|
6
|
+
getState(name: string): IAnimationStateConfig | undefined;
|
|
7
|
+
getRule(name: string): IAnimationStateRule | undefined;
|
|
8
|
+
hasConflict(stateA: string, stateB: string): boolean;
|
|
9
|
+
canInterrupt(stateA: string, stateB: string): boolean;
|
|
10
|
+
isQueueable(state: string): boolean;
|
|
11
|
+
getTransitionDelay(state: string): number;
|
|
12
|
+
getAllStateNames(): string[];
|
|
13
|
+
clear(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class AnimationStateRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.states = new Map, this.rules = new Map;
|
|
4
|
+
}
|
|
5
|
+
register(state, rule) {
|
|
6
|
+
var _a;
|
|
7
|
+
const {name: name} = state;
|
|
8
|
+
name ? (this.states.set(name, Object.assign(Object.assign({}, state), {
|
|
9
|
+
priority: null !== (_a = state.priority) && void 0 !== _a ? _a : 0
|
|
10
|
+
})), rule && this.rules.set(name, rule)) : console.warn("Animation state must have a name");
|
|
11
|
+
}
|
|
12
|
+
getState(name) {
|
|
13
|
+
return this.states.get(name);
|
|
14
|
+
}
|
|
15
|
+
getRule(name) {
|
|
16
|
+
return this.rules.get(name);
|
|
17
|
+
}
|
|
18
|
+
hasConflict(stateA, stateB) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
if (stateA === stateB) return !1;
|
|
21
|
+
const ruleA = this.getRule(stateA), ruleB = this.getRule(stateB);
|
|
22
|
+
return !!(null === (_a = null == ruleA ? void 0 : ruleA.conflicts) || void 0 === _a ? void 0 : _a.includes(stateB)) || !!(null === (_b = null == ruleB ? void 0 : ruleB.conflicts) || void 0 === _b ? void 0 : _b.includes(stateA));
|
|
23
|
+
}
|
|
24
|
+
canInterrupt(stateA, stateB) {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const ruleA = this.getRule(stateA), stateAConfig = this.getState(stateA), stateBConfig = this.getState(stateB);
|
|
27
|
+
return !!(stateAConfig && stateBConfig && (null !== (_a = stateBConfig.priority) && void 0 !== _a ? _a : 0) > (null !== (_b = stateAConfig.priority) && void 0 !== _b ? _b : 0)) || !!(null === (_c = null == ruleA ? void 0 : ruleA.interruptibleBy) || void 0 === _c ? void 0 : _c.includes(stateB));
|
|
28
|
+
}
|
|
29
|
+
isQueueable(state) {
|
|
30
|
+
const rule = this.getRule(state);
|
|
31
|
+
return !!(null == rule ? void 0 : rule.queueable);
|
|
32
|
+
}
|
|
33
|
+
getTransitionDelay(state) {
|
|
34
|
+
var _a;
|
|
35
|
+
const rule = this.getRule(state);
|
|
36
|
+
return null !== (_a = null == rule ? void 0 : rule.transitionDelay) && void 0 !== _a ? _a : 0;
|
|
37
|
+
}
|
|
38
|
+
getAllStateNames() {
|
|
39
|
+
return Array.from(this.states.keys());
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
this.states.clear(), this.rules.clear();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=animation-state-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/animation-state-registry.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,sBAAsB;IAAnC;QACU,WAAM,GAAuC,IAAI,GAAG,EAAE,CAAC;QACvD,UAAK,GAAqC,IAAI,GAAG,EAAE,CAAC;IA0G9D,CAAC;IArGC,QAAQ,CAAC,KAA4B,EAAE,IAA0B;;QAC/D,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,IAAI,EAAE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GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAG3C,IAAI,YAAY,IAAI,YAAY,IAAI,CAAC,MAAA,YAAY,CAAC,QAAQ,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,YAAY,CAAC,QAAQ,mCAAI,CAAC,CAAC,EAAE;YAC/F,OAAO,IAAI,CAAC;SACb;QAGD,OAAO,CAAC,CAAC,CAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,0CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA,CAAC;IACpD,CAAC;IAKD,WAAW,CAAC,KAAa;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,CAAA,CAAC;IAC3B,CAAC;IAKD,kBAAkB,CAAC,KAAa;;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe,mCAAI,CAAC,CAAC;IACpC,CAAC;IAKD,gBAAgB;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;IAKD,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF","file":"animation-state-registry.js","sourcesContent":["import type { IAnimationStateConfig, IAnimationStateRegistry, IAnimationStateRule } from '../intreface/state';\n\n/**\n * Registry for animation states and their rules\n */\nexport class AnimationStateRegistry implements IAnimationStateRegistry {\n private states: Map<string, IAnimationStateConfig> = new Map();\n private rules: Map<string, IAnimationStateRule> = new Map();\n\n /**\n * Register a state with its animation config and rules\n */\n register(state: IAnimationStateConfig, rule?: IAnimationStateRule): void {\n const { name } = state;\n\n if (!name) {\n console.warn('Animation state must have a name');\n return;\n }\n\n this.states.set(name, {\n ...state,\n priority: state.priority ?? 0\n });\n\n if (rule) {\n this.rules.set(name, rule);\n }\n }\n\n /**\n * Get state configuration by name\n */\n getState(name: string): IAnimationStateConfig | undefined {\n return this.states.get(name);\n }\n\n /**\n * Get state rule by name\n */\n getRule(name: string): IAnimationStateRule | undefined {\n return this.rules.get(name);\n }\n\n /**\n * Check if two states conflict with each other\n */\n hasConflict(stateA: string, stateB: string): boolean {\n if (stateA === stateB) {\n return false; // Same state doesn't conflict with itself\n }\n\n const ruleA = this.getRule(stateA);\n const ruleB = this.getRule(stateB);\n\n if (ruleA?.conflicts?.includes(stateB)) {\n return true;\n }\n\n if (ruleB?.conflicts?.includes(stateA)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Check if stateB can interrupt stateA\n */\n canInterrupt(stateA: string, stateB: string): boolean {\n const ruleA = this.getRule(stateA);\n const stateAConfig = this.getState(stateA);\n const stateBConfig = this.getState(stateB);\n\n // Higher priority can always interrupt\n if (stateAConfig && stateBConfig && (stateBConfig.priority ?? 0) > (stateAConfig.priority ?? 0)) {\n return true;\n }\n\n // Check if explicitly interruptible\n return !!ruleA?.interruptibleBy?.includes(stateB);\n }\n\n /**\n * Check if a state is queueable\n */\n isQueueable(state: string): boolean {\n const rule = this.getRule(state);\n return !!rule?.queueable;\n }\n\n /**\n * Get transition delay for a state\n */\n getTransitionDelay(state: string): number {\n const rule = this.getRule(state);\n return rule?.transitionDelay ?? 0;\n }\n\n /**\n * Get all registered state names\n */\n getAllStateNames(): string[] {\n return Array.from(this.states.keys());\n }\n\n /**\n * Clear all registered states and rules\n */\n clear(): void {\n this.states.clear();\n this.rules.clear();\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { IAnimationState } from './types';
|
|
3
|
+
import type { IAnimationConfig } from '../executor/executor';
|
|
4
|
+
import { AnimateExecutor } from '../executor/animate-executor';
|
|
5
|
+
export declare class AnimationStateStore {
|
|
6
|
+
graphic: IGraphic;
|
|
7
|
+
constructor(graphic: IGraphic);
|
|
8
|
+
states?: Map<string, IAnimationState>;
|
|
9
|
+
registerState(state: IAnimationState): void;
|
|
10
|
+
clearStates(): void;
|
|
11
|
+
}
|
|
12
|
+
interface IStateInfo {
|
|
13
|
+
state: string;
|
|
14
|
+
animationConfig: IAnimationConfig;
|
|
15
|
+
executor: AnimateExecutor;
|
|
16
|
+
}
|
|
17
|
+
export declare class AnimationStateManager {
|
|
18
|
+
protected graphic: IGraphic;
|
|
19
|
+
stateList: IStateInfo[] | null;
|
|
20
|
+
constructor(graphic: IGraphic);
|
|
21
|
+
applyState(nextState: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): void;
|
|
22
|
+
stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void;
|
|
23
|
+
clearState(): void;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AnimationTransitionRegistry } from "./animation-states-registry";
|
|
2
|
+
|
|
3
|
+
import { AnimateExecutor } from "../executor/animate-executor";
|
|
4
|
+
|
|
5
|
+
export class AnimationStateStore {
|
|
6
|
+
constructor(graphic) {
|
|
7
|
+
this.graphic = graphic;
|
|
8
|
+
}
|
|
9
|
+
registerState(state) {
|
|
10
|
+
this.states || (this.states = new Map), this.states.set(state.name, state);
|
|
11
|
+
}
|
|
12
|
+
clearStates() {
|
|
13
|
+
var _a;
|
|
14
|
+
null === (_a = this.states) || void 0 === _a || _a.clear();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class AnimationStateManager {
|
|
19
|
+
constructor(graphic) {
|
|
20
|
+
this.stateList = null, this.graphic = graphic;
|
|
21
|
+
}
|
|
22
|
+
applyState(nextState, animationConfig, callback) {
|
|
23
|
+
const registry = AnimationTransitionRegistry.getInstance(), shouldStopState = [], shouldApplyState = [];
|
|
24
|
+
if (this.stateList && this.stateList.length ? nextState.forEach(((state, index) => {
|
|
25
|
+
const result = {
|
|
26
|
+
allowTransition: !0,
|
|
27
|
+
stopOriginalTransition: !0
|
|
28
|
+
};
|
|
29
|
+
this.stateList.forEach((currState => {
|
|
30
|
+
const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);
|
|
31
|
+
result.allowTransition = result.allowTransition && _result.allowTransition;
|
|
32
|
+
})), result.allowTransition && (shouldApplyState.push({
|
|
33
|
+
state: state,
|
|
34
|
+
animationConfig: animationConfig[index].animation,
|
|
35
|
+
executor: new AnimateExecutor(this.graphic)
|
|
36
|
+
}), this.stateList.forEach((currState => {
|
|
37
|
+
registry.isTransitionAllowed(currState.state, state, this.graphic).stopOriginalTransition && shouldStopState.push(currState);
|
|
38
|
+
})));
|
|
39
|
+
})) : nextState.forEach(((state, index) => {
|
|
40
|
+
shouldApplyState.push({
|
|
41
|
+
state: state,
|
|
42
|
+
animationConfig: animationConfig[index].animation,
|
|
43
|
+
executor: new AnimateExecutor(this.graphic)
|
|
44
|
+
});
|
|
45
|
+
})), shouldStopState.forEach((state => {
|
|
46
|
+
state.executor.stop();
|
|
47
|
+
})), shouldApplyState.length) {
|
|
48
|
+
shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);
|
|
49
|
+
for (let i = 0; i < shouldApplyState.length; i++) {
|
|
50
|
+
const nextState = shouldApplyState[i + 1], currentState = shouldApplyState[i];
|
|
51
|
+
currentState.executor.onEnd((() => {
|
|
52
|
+
nextState && nextState.executor.execute(nextState.animationConfig), this.stateList = this.stateList.filter((state => state !== currentState)),
|
|
53
|
+
i === shouldApplyState.length - 1 && callback && callback(!1);
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
} else callback && callback(!0);
|
|
57
|
+
this.stateList ? this.stateList = this.stateList.filter((state => !shouldStopState.includes(state))) : this.stateList = [],
|
|
58
|
+
this.stateList.push(...shouldApplyState);
|
|
59
|
+
}
|
|
60
|
+
stopState(state, type) {
|
|
61
|
+
var _a;
|
|
62
|
+
const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find((stateInfo => stateInfo.state === state));
|
|
63
|
+
stateInfo && stateInfo.executor.stop(type);
|
|
64
|
+
}
|
|
65
|
+
clearState() {
|
|
66
|
+
var _a;
|
|
67
|
+
null === (_a = this.stateList) || void 0 === _a || _a.forEach((state => {
|
|
68
|
+
state.executor.stop();
|
|
69
|
+
})), this.stateList = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=animation-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/animation-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,OAAO,mBAAmB;IAG9B,YAAY,OAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAMD,aAAa,CAAC,KAAsB;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,WAAW;;QACT,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AASD,MAAM,OAAO,qBAAqB;IAOhC,YAAY,OAAiB;QAF7B,cAAS,GAAwB,IAAI,CAAC;QAGpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IASD,UAAU,CAAC,SAAmB,EAAE,eAAkC,EAAE,QAAoC;QACtG,MAAM,QAAQ,GAAG,2BAA2B,CAAC,WAAW,EAAE,CAA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,CAAC,CAAC;SAChB;QAED,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SACnF;aAAM;YACL,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;SACrB;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;IAC3C,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAA4C;;QACnE,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/E,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,UAAU;;QAER,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,CAAC,KAAK,CAAC,EAAE;YAC9B,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CAKF","file":"animation-state.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig;\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(nextState: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: animationConfig[index].animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: animationConfig[index].animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
interface ITransitionResult {
|
|
3
|
+
allowTransition: boolean;
|
|
4
|
+
stopOriginalTransition: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type TransitionFunction = (graphic: IGraphic, fromState: string) => ITransitionResult;
|
|
7
|
+
export declare class AnimationTransitionRegistry {
|
|
8
|
+
private static instance;
|
|
9
|
+
private transitions;
|
|
10
|
+
constructor();
|
|
11
|
+
static getInstance(): AnimationTransitionRegistry;
|
|
12
|
+
private registerDefaultTransitions;
|
|
13
|
+
isTransitionAllowed(fromState: string, toState: string, graphic: IGraphic): ITransitionResult;
|
|
14
|
+
registerTransition(fromState: string, toState: string, transition: TransitionFunction): void;
|
|
15
|
+
}
|
|
16
|
+
declare const transitionRegistry: AnimationTransitionRegistry;
|
|
17
|
+
export { transitionRegistry };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class AnimationTransitionRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.transitions = new Map, this.registerDefaultTransitions();
|
|
4
|
+
}
|
|
5
|
+
static getInstance() {
|
|
6
|
+
return AnimationTransitionRegistry.instance || (AnimationTransitionRegistry.instance = new AnimationTransitionRegistry),
|
|
7
|
+
AnimationTransitionRegistry.instance;
|
|
8
|
+
}
|
|
9
|
+
registerDefaultTransitions() {
|
|
10
|
+
this.registerTransition("appear", "*", (() => ({
|
|
11
|
+
allowTransition: !0,
|
|
12
|
+
stopOriginalTransition: !1
|
|
13
|
+
}))), this.registerTransition("appear", "appear", (() => ({
|
|
14
|
+
allowTransition: !1,
|
|
15
|
+
stopOriginalTransition: !1
|
|
16
|
+
}))), this.registerTransition("appear", "disappear", (() => ({
|
|
17
|
+
allowTransition: !0,
|
|
18
|
+
stopOriginalTransition: !0
|
|
19
|
+
}))), this.registerTransition("appear", "exit", (() => ({
|
|
20
|
+
allowTransition: !0,
|
|
21
|
+
stopOriginalTransition: !0
|
|
22
|
+
}))), this.registerTransition("normal", "*", (() => ({
|
|
23
|
+
allowTransition: !0,
|
|
24
|
+
stopOriginalTransition: !1
|
|
25
|
+
}))), this.registerTransition("normal", "normal", (() => ({
|
|
26
|
+
allowTransition: !1,
|
|
27
|
+
stopOriginalTransition: !1
|
|
28
|
+
}))), this.registerTransition("normal", "disappear", (() => ({
|
|
29
|
+
allowTransition: !0,
|
|
30
|
+
stopOriginalTransition: !0
|
|
31
|
+
}))), this.registerTransition("normal", "exit", (() => ({
|
|
32
|
+
allowTransition: !0,
|
|
33
|
+
stopOriginalTransition: !0
|
|
34
|
+
}))), this.registerTransition("exit", "*", (() => ({
|
|
35
|
+
allowTransition: !1,
|
|
36
|
+
stopOriginalTransition: !1
|
|
37
|
+
}))), this.registerTransition("exit", "disappear", (() => ({
|
|
38
|
+
allowTransition: !0,
|
|
39
|
+
stopOriginalTransition: !0
|
|
40
|
+
}))), this.registerTransition("exit", "enter", (() => ({
|
|
41
|
+
allowTransition: !0,
|
|
42
|
+
stopOriginalTransition: !0
|
|
43
|
+
}))), this.registerTransition("exit", "exit", (() => ({
|
|
44
|
+
allowTransition: !1,
|
|
45
|
+
stopOriginalTransition: !1
|
|
46
|
+
}))), this.registerTransition("enter", "*", (() => ({
|
|
47
|
+
allowTransition: !0,
|
|
48
|
+
stopOriginalTransition: !1
|
|
49
|
+
}))), this.registerTransition("enter", "enter", (() => ({
|
|
50
|
+
allowTransition: !1,
|
|
51
|
+
stopOriginalTransition: !1
|
|
52
|
+
}))), this.registerTransition("enter", "disappear", (() => ({
|
|
53
|
+
allowTransition: !0,
|
|
54
|
+
stopOriginalTransition: !0
|
|
55
|
+
}))), this.registerTransition("enter", "exit", (() => ({
|
|
56
|
+
allowTransition: !0,
|
|
57
|
+
stopOriginalTransition: !0
|
|
58
|
+
}))), this.registerTransition("disappear", "*", (() => ({
|
|
59
|
+
allowTransition: !1,
|
|
60
|
+
stopOriginalTransition: !1
|
|
61
|
+
}))), this.registerTransition("disappear", "appear", (() => ({
|
|
62
|
+
allowTransition: !0,
|
|
63
|
+
stopOriginalTransition: !0
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
66
|
+
isTransitionAllowed(fromState, toState, graphic) {
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
|
+
let func = null === (_a = this.transitions.get(fromState)) || void 0 === _a ? void 0 : _a.get(toState);
|
|
69
|
+
return func ? func(graphic, fromState) : (func = null === (_b = this.transitions.get(fromState)) || void 0 === _b ? void 0 : _b.get("*"),
|
|
70
|
+
func ? func(graphic, fromState) : (func = null === (_c = this.transitions.get("*")) || void 0 === _c ? void 0 : _c.get(toState),
|
|
71
|
+
func ? func(graphic, fromState) : (func = null === (_d = this.transitions.get("*")) || void 0 === _d ? void 0 : _d.get("*"),
|
|
72
|
+
func ? func(graphic, fromState) : {
|
|
73
|
+
allowTransition: !0,
|
|
74
|
+
stopOriginalTransition: !0
|
|
75
|
+
})));
|
|
76
|
+
}
|
|
77
|
+
registerTransition(fromState, toState, transition) {
|
|
78
|
+
let fromStateMap = this.transitions.get(fromState);
|
|
79
|
+
fromStateMap || (fromStateMap = new Map, this.transitions.set(fromState, fromStateMap)),
|
|
80
|
+
fromStateMap.set(toState, transition);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const transitionRegistry = AnimationTransitionRegistry.getInstance();
|
|
85
|
+
|
|
86
|
+
export { transitionRegistry };
|
|
87
|
+
//# sourceMappingURL=animation-states-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/animation-states-registry.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,2BAA2B;IAMtC;QAFQ,gBAAW,GAAiD,IAAI,GAAG,EAAE,CAAC;QAG5E,IAAI,CAAC,0BAA0B,EAAE,CAAC;IACpC,CAAC;IAKD,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,2BAA2B,CAAC,QAAQ,EAAE;YACzC,2BAA2B,CAAC,QAAQ,GAAG,IAAI,2BAA2B,EAAE,CAAC;SAC1E;QACD,OAAO,2BAA2B,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAKO,0BAA0B;QAEhC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;YAC5C,eAAe,EAAE,IAAI;YACrB,sBAAsB,EAAE,KAAK;SAC9B,CAAC,CAAC,C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YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEnD,IAAI,CAAC,YAAY,EAAE;YACjB,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;SAC/C;QAED,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;CACF;AAGD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,WAAW,EAAE,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,CAAC","file":"animation-states-registry.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\n\ninterface ITransitionResult {\n allowTransition: boolean;\n stopOriginalTransition: boolean;\n}\n\n/**\n * 注册动画状态切换的转换函数\n */\nexport type TransitionFunction = (graphic: IGraphic, fromState: string) => ITransitionResult;\n\n/**\n * 动画状态切换的注册表\n * 管理所有图形的动画状态切换逻辑\n */\nexport class AnimationTransitionRegistry {\n private static instance: AnimationTransitionRegistry;\n\n // 源状态到目标状态的映射,每个目标状态都有一个转换函数\n private transitions: Map<string, Map<string, TransitionFunction>> = new Map();\n\n constructor() {\n this.registerDefaultTransitions();\n }\n\n /**\n * 获取注册表的单例实例\n */\n static getInstance(): AnimationTransitionRegistry {\n if (!AnimationTransitionRegistry.instance) {\n AnimationTransitionRegistry.instance = new AnimationTransitionRegistry();\n }\n return AnimationTransitionRegistry.instance;\n }\n\n /**\n * 注册默认的转换规则\n */\n private registerDefaultTransitions(): void {\n // appear动画,可以被任何动画覆盖,但不会停止(disappear、exit除外)\n this.registerTransition('appear', '*', () => ({\n allowTransition: true,\n stopOriginalTransition: false\n }));\n // appear 动画碰到appear动画,什么都不会发生\n this.registerTransition('appear', 'appear', () => ({\n allowTransition: false,\n stopOriginalTransition: false\n }));\n this.registerTransition('appear', 'disappear', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n this.registerTransition('appear', 'exit', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n\n // 循环动画(normal),可以被任何动画覆盖,但不会停止(disappear、exit除外)\n this.registerTransition('normal', '*', () => ({\n allowTransition: true,\n stopOriginalTransition: false\n }));\n // 循环动画碰到循环动画,什么都不会发生\n this.registerTransition('normal', 'normal', () => ({\n allowTransition: false,\n stopOriginalTransition: false\n }));\n this.registerTransition('normal', 'disappear', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n this.registerTransition('normal', 'exit', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n\n // 退出动画不能被覆盖或停止(disappear除外)\n this.registerTransition('exit', '*', () => ({\n allowTransition: false,\n stopOriginalTransition: false\n }));\n this.registerTransition('exit', 'disappear', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n // 退出动画碰到enter动画,会立即停止\n this.registerTransition('exit', 'enter', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n // 退出动画碰到退出,什么都不会发生\n this.registerTransition('exit', 'exit', () => ({\n allowTransition: false,\n stopOriginalTransition: false\n }));\n\n // enter 动画可以被任何动画覆盖,但不会停止(exit、disappear除外)\n this.registerTransition('enter', '*', () => ({\n allowTransition: true,\n stopOriginalTransition: false\n }));\n // enter 动画碰到enter动画,什么都不会发生\n this.registerTransition('enter', 'enter', () => ({\n allowTransition: false,\n stopOriginalTransition: false\n }));\n this.registerTransition('enter', 'disappear', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n this.registerTransition('enter', 'exit', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n\n // disappear 动画碰到任何动画,什么都不会发生(appear除外)\n this.registerTransition('disappear', '*', () => ({\n allowTransition: false,\n stopOriginalTransition: false\n }));\n\n // disappear 动画碰到appear动画,会立即停止\n this.registerTransition('disappear', 'appear', () => ({\n allowTransition: true,\n stopOriginalTransition: true\n }));\n }\n\n /**\n * 检查两个状态之间是否允许转换\n */\n isTransitionAllowed(fromState: string, toState: string, graphic: IGraphic): ITransitionResult {\n // 直接转换规则\n let func = this.transitions.get(fromState)?.get(toState);\n if (func) {\n return func(graphic, fromState);\n }\n\n // 状态到通配符\n func = this.transitions.get(fromState)?.get('*');\n if (func) {\n return func(graphic, fromState);\n }\n\n // 通配符到状态\n func = this.transitions.get('*')?.get(toState);\n if (func) {\n return func(graphic, fromState);\n }\n\n // 通配符到通配符\n func = this.transitions.get('*')?.get('*');\n if (func) {\n return func(graphic, fromState);\n }\n\n // 默认允许转换\n return {\n allowTransition: true,\n stopOriginalTransition: true\n };\n }\n\n /**\n * 注册两个状态之间的转换\n */\n registerTransition(fromState: string, toState: string, transition: TransitionFunction): void {\n let fromStateMap = this.transitions.get(fromState);\n\n if (!fromStateMap) {\n fromStateMap = new Map();\n this.transitions.set(fromState, fromStateMap);\n }\n\n fromStateMap.set(toState, transition);\n }\n}\n\n// 初始化单例转换注册表\nconst transitionRegistry = AnimationTransitionRegistry.getInstance();\n\nexport { transitionRegistry };\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { IAnimationState } from './types';
|
|
3
|
+
import { AnimationStateManager, AnimationStateStore } from './animation-state';
|
|
4
|
+
export declare class GraphicStateExtension {
|
|
5
|
+
_getAnimationStateManager(graphic: IGraphic): AnimationStateManager;
|
|
6
|
+
_getAnimationStateStore(graphic: IGraphic): AnimationStateStore;
|
|
7
|
+
registerAnimationState(state: IAnimationState): this;
|
|
8
|
+
applyAnimationState(state: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): this;
|
|
9
|
+
stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>): this;
|
|
10
|
+
clearAnimationStates(): this;
|
|
11
|
+
static extend(graphic: IGraphic): IGraphic;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AnimationStateManager, AnimationStateStore } from "./animation-state";
|
|
2
|
+
|
|
3
|
+
export class GraphicStateExtension {
|
|
4
|
+
_getAnimationStateManager(graphic) {
|
|
5
|
+
return graphic._animationStateManager || (graphic._animationStateManager = new AnimationStateManager(graphic)),
|
|
6
|
+
graphic._animationStateManager;
|
|
7
|
+
}
|
|
8
|
+
_getAnimationStateStore(graphic) {
|
|
9
|
+
return graphic._animationStateStore || (graphic._animationStateStore = new AnimationStateStore(graphic)),
|
|
10
|
+
graphic._animationStateStore;
|
|
11
|
+
}
|
|
12
|
+
registerAnimationState(state) {
|
|
13
|
+
return this._getAnimationStateStore(this).registerState(state), this;
|
|
14
|
+
}
|
|
15
|
+
applyAnimationState(state, animationConfig, callback) {
|
|
16
|
+
return this._getAnimationStateManager(this).applyState(state, animationConfig, callback),
|
|
17
|
+
this;
|
|
18
|
+
}
|
|
19
|
+
stopAnimationState(state, type) {
|
|
20
|
+
return this._getAnimationStateManager(this).stopState(state, type), this;
|
|
21
|
+
}
|
|
22
|
+
clearAnimationStates() {
|
|
23
|
+
return this._getAnimationStateManager(this).clearState(), this;
|
|
24
|
+
}
|
|
25
|
+
static extend(graphic) {
|
|
26
|
+
return (new GraphicStateExtension)._getAnimationStateManager(graphic), graphic;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=graphic-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/graphic-extension.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAK/E,MAAM,OAAO,qBAAqB;IAChC,yBAAyB,CAAC,OAAiB;QACzC,IAAI,CAAE,OAAe,CAAC,sBAAsB,EAAE;YAE3C,OAAe,CAAC,sBAAsB,GAAG,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;SAC9E;QACD,OAAQ,OAAe,CAAC,sBAAsB,CAAC;IACjD,CAAC;IACD,uBAAuB,CAAC,OAAiB;QACvC,IAAI,CAAE,OAAe,CAAC,oBAAoB,EAAE;YAEzC,OAAe,CAAC,oBAAoB,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;SAC1E;QACD,OAAQ,OAAe,CAAC,oBAAoB,CAAC;IAC/C,CAAC;IAKD,sBAAsB,CAAC,KAAsB;QAC3C,IAAI,CAAC,uBAAuB,CAAC,IAA2B,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,mBAAmB,CAAC,KAAe,EAAE,eAAkC,EAAE,QAAoC;QAC3G,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,kBAAkB,CAAC,KAAa,EAAE,IAA4C;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,oBAAoB;QAClB,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IAYD,MAAM,CAAC,MAAM,CAAC,OAAiB;QAC7B,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC9C,SAAS,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","file":"graphic-extension.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationStateManager, AnimationStateStore } from './animation-state';\n\n/**\n * 将动画状态方法作为混入扩展 Graphic 的类\n */\nexport class GraphicStateExtension {\n _getAnimationStateManager(graphic: IGraphic): AnimationStateManager {\n if (!(graphic as any)._animationStateManager) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateManager = new AnimationStateManager(graphic);\n }\n return (graphic as any)._animationStateManager;\n }\n _getAnimationStateStore(graphic: IGraphic): AnimationStateStore {\n if (!(graphic as any)._animationStateStore) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateStore = new AnimationStateStore(graphic);\n }\n return (graphic as any)._animationStateStore;\n }\n\n /**\n * 注册一个动画状态\n */\n registerAnimationState(state: IAnimationState): this {\n this._getAnimationStateStore(this as unknown as IGraphic).registerState(state);\n return this;\n }\n\n /**\n * 应用一个动画状态到图形\n */\n applyAnimationState(state: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyState(state, animationConfig, callback);\n return this;\n }\n\n /**\n * 停止一个动画状态\n */\n stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>): this {\n this._getAnimationStateManager(this as unknown as IGraphic).stopState(state, type);\n return this;\n }\n\n /**\n * 清除图形上的所有动画状态\n */\n clearAnimationStates(): this {\n this._getAnimationStateManager(this as unknown as IGraphic).clearState();\n return this;\n }\n\n // /**\n // * 获取图形当前的动画状态\n // */\n // getCurrentAnimationState(): string[] | null {\n // return this._getAnimationStateManager(this as unknown as IGraphic).getCurrentState();\n // }\n\n /**\n * 继承\n */\n static extend(graphic: IGraphic): IGraphic {\n const extension = new GraphicStateExtension();\n extension._getAnimationStateManager(graphic);\n return graphic;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC","file":"index.js","sourcesContent":["export * from './animation-state';\nexport * from './graphic-extension';\nexport * from './animation-states-registry';\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IAnimationConfig } from '../executor/executor';
|
|
2
|
+
export interface IAnimationState {
|
|
3
|
+
name: string;
|
|
4
|
+
animation: IAnimationConfig;
|
|
5
|
+
}
|
|
6
|
+
export interface IAnimationStateManager {
|
|
7
|
+
registerState: (state: IAnimationState) => void;
|
|
8
|
+
applyState: (state: string | string[]) => void;
|
|
9
|
+
clearStates: () => void;
|
|
10
|
+
getCurrentState: () => string | string[] | null;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state/types.ts"],"names":[],"mappings":"","file":"types.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationConfig } from '../executor/executor';\n\nexport interface IAnimationState {\n /**\n * 状态名称\n */\n name: string;\n\n /**\n * 动画配置\n */\n animation: IAnimationConfig;\n}\n\n/**\n * Animation state manager for a graphic\n */\nexport interface IAnimationStateManager {\n /**\n * Register a state for the graphic\n */\n registerState: (state: IAnimationState) => void;\n\n /**\n * Apply a state to the graphic\n */\n applyState: (state: string | string[]) => void;\n\n /**\n * Clear all states from the graphic\n */\n clearStates: () => void;\n\n /**\n * Get the current state of the graphic\n */\n getCurrentState: () => string | string[] | null;\n}\n"]}
|
package/es/step.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { IAnimate, IStep } from './intreface/animate';
|
|
3
|
+
import type { EasingType, EasingTypeFunc } from './intreface/easing';
|
|
4
|
+
import type { IAnimateStepType } from './intreface/type';
|
|
5
|
+
export declare class Step implements IStep {
|
|
6
|
+
type: IAnimateStepType;
|
|
7
|
+
prev?: IStep;
|
|
8
|
+
duration: number;
|
|
9
|
+
next?: IStep;
|
|
10
|
+
props?: Record<string, any>;
|
|
11
|
+
propKeys?: string[];
|
|
12
|
+
interpolateUpdateFunctions?: ((key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void)[];
|
|
13
|
+
easing: EasingTypeFunc;
|
|
14
|
+
animate: IAnimate;
|
|
15
|
+
target: IGraphic;
|
|
16
|
+
fromProps: Record<string, any>;
|
|
17
|
+
fromParsedProps: Record<string, any>;
|
|
18
|
+
toParsedProps: Record<string, any>;
|
|
19
|
+
protected _startTime: number;
|
|
20
|
+
_hasFirstRun: boolean;
|
|
21
|
+
protected _endCb?: (animate: IAnimate, step: IStep) => void;
|
|
22
|
+
constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType);
|
|
23
|
+
bind(target: IGraphic, animate: IAnimate): void;
|
|
24
|
+
append(step: IStep): void;
|
|
25
|
+
private updateDownstreamStartTimes;
|
|
26
|
+
getLastProps(): any;
|
|
27
|
+
setDuration(duration: number, updateDownstream?: boolean): void;
|
|
28
|
+
getDuration(): number;
|
|
29
|
+
determineInterpolateUpdateFunction(): void;
|
|
30
|
+
setStartTime(time: number, updateDownstream?: boolean): void;
|
|
31
|
+
getStartTime(): number;
|
|
32
|
+
onBind(): void;
|
|
33
|
+
onFirstRun(): void;
|
|
34
|
+
onStart(): void;
|
|
35
|
+
protected tryPreventConflict(): void;
|
|
36
|
+
deleteSelfAttr(key: string): void;
|
|
37
|
+
trySyncStartProps(): void;
|
|
38
|
+
update(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
39
|
+
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
40
|
+
onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
|
|
41
|
+
getEndProps(): Record<string, any>;
|
|
42
|
+
getFromProps(): Record<string, any>;
|
|
43
|
+
getMergedEndProps(): Record<string, any> | void;
|
|
44
|
+
}
|
|
45
|
+
export declare class WaitStep extends Step {
|
|
46
|
+
constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType);
|
|
47
|
+
update(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
48
|
+
determineInterpolateUpdateFunction(): void;
|
|
49
|
+
}
|
package/es/step.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ColorStore, ColorType } from "@visactor/vrender-core";
|
|
2
|
+
|
|
3
|
+
import { Easing } from "./utils/easing";
|
|
4
|
+
|
|
5
|
+
import { commonInterpolateUpdate, interpolateUpdateStore } from "./interpolate/store";
|
|
6
|
+
|
|
7
|
+
import { isString } from "@visactor/vutils";
|
|
8
|
+
|
|
9
|
+
function noop() {}
|
|
10
|
+
|
|
11
|
+
export class Step {
|
|
12
|
+
constructor(type, props, duration, easing) {
|
|
13
|
+
this._startTime = 0, this._hasFirstRun = !1, this.type = type, this.props = props,
|
|
14
|
+
this.duration = duration, this.easing = easing ? "function" == typeof easing ? easing : Easing[easing] : Easing.linear,
|
|
15
|
+
"wait" === type && (this.onUpdate = noop);
|
|
16
|
+
}
|
|
17
|
+
bind(target, animate) {
|
|
18
|
+
this.target = target, this.animate = animate, this.onBind();
|
|
19
|
+
}
|
|
20
|
+
append(step) {
|
|
21
|
+
this.next = step, step.prev = this, step.setStartTime(this.getStartTime() + this.duration, !1);
|
|
22
|
+
}
|
|
23
|
+
updateDownstreamStartTimes() {
|
|
24
|
+
let currentStep = this.next, currentStartTime = this._startTime + this.duration;
|
|
25
|
+
for (;currentStep; ) currentStep.setStartTime(currentStartTime, !1), currentStartTime += currentStep.duration,
|
|
26
|
+
currentStep = currentStep.next;
|
|
27
|
+
this.animate.updateDuration();
|
|
28
|
+
}
|
|
29
|
+
getLastProps() {
|
|
30
|
+
return this.prev ? this.prev.props || {} : this.animate.getStartProps();
|
|
31
|
+
}
|
|
32
|
+
setDuration(duration, updateDownstream = !0) {
|
|
33
|
+
this.duration = duration, updateDownstream && this.updateDownstreamStartTimes();
|
|
34
|
+
}
|
|
35
|
+
getDuration() {
|
|
36
|
+
return this.duration;
|
|
37
|
+
}
|
|
38
|
+
determineInterpolateUpdateFunction() {
|
|
39
|
+
if (!this.props) return;
|
|
40
|
+
const funcs = [];
|
|
41
|
+
this.propKeys.forEach((key => {
|
|
42
|
+
if ("fill" === key || "stroke" === key) {
|
|
43
|
+
const from = this.getLastProps()[key], to = this.props[key];
|
|
44
|
+
if (isString(from) && isString(to)) {
|
|
45
|
+
const fromArray = ColorStore.Get(from, ColorType.Color255), toArray = ColorStore.Get(to, ColorType.Color255);
|
|
46
|
+
this.fromParsedProps || (this.fromParsedProps = {}), this.toParsedProps || (this.toParsedProps = {}),
|
|
47
|
+
this.fromParsedProps[key] = fromArray, this.toParsedProps[key] = toArray;
|
|
48
|
+
}
|
|
49
|
+
funcs.push(interpolateUpdateStore["fill" === key ? "fillPure" : "strokePure"]);
|
|
50
|
+
} else interpolateUpdateStore[key] ? funcs.push(interpolateUpdateStore[key]) : funcs.push(commonInterpolateUpdate);
|
|
51
|
+
})), this.interpolateUpdateFunctions = funcs;
|
|
52
|
+
}
|
|
53
|
+
setStartTime(time, updateDownstream = !0) {
|
|
54
|
+
this._startTime = time, updateDownstream && this.updateDownstreamStartTimes();
|
|
55
|
+
}
|
|
56
|
+
getStartTime() {
|
|
57
|
+
return this._startTime;
|
|
58
|
+
}
|
|
59
|
+
onBind() {}
|
|
60
|
+
onFirstRun() {}
|
|
61
|
+
onStart() {
|
|
62
|
+
this._hasFirstRun || (this._hasFirstRun = !0, this.fromProps = this.getLastProps(),
|
|
63
|
+
this.determineInterpolateUpdateFunction(), this.tryPreventConflict(), this.trySyncStartProps(),
|
|
64
|
+
this.onFirstRun());
|
|
65
|
+
}
|
|
66
|
+
tryPreventConflict() {
|
|
67
|
+
const animate = this.animate;
|
|
68
|
+
this.target.animates.forEach((a => {
|
|
69
|
+
if (a === animate || a.priority > animate.priority) return;
|
|
70
|
+
const fromProps = a.getStartProps();
|
|
71
|
+
this.propKeys.forEach((key => {
|
|
72
|
+
null != fromProps[key] && a.preventAttr(key);
|
|
73
|
+
}));
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
deleteSelfAttr(key) {
|
|
77
|
+
var _a;
|
|
78
|
+
delete this.props[key], this.fromProps && delete this.fromProps[key];
|
|
79
|
+
const index = this.propKeys.indexOf(key);
|
|
80
|
+
-1 !== index && (this.propKeys.splice(index, 1), null === (_a = this.interpolateUpdateFunctions) || void 0 === _a || _a.splice(index, 1));
|
|
81
|
+
}
|
|
82
|
+
trySyncStartProps() {
|
|
83
|
+
this.propKeys.forEach((key => {
|
|
84
|
+
this.fromProps[key] = this.animate.target.getComputedAttribute(key);
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
update(end, ratio, out) {
|
|
88
|
+
if (this.onStart(), !this.props || !this.propKeys) return;
|
|
89
|
+
const easedRatio = this.easing(ratio);
|
|
90
|
+
this.animate.interpolateUpdateFunction ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target) : this.interpolateUpdateFunctions.forEach(((func, index) => {
|
|
91
|
+
if (!this.animate.validAttr(this.propKeys[index])) return;
|
|
92
|
+
const key = this.propKeys[index];
|
|
93
|
+
func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
|
|
94
|
+
})), this.onUpdate(end, easedRatio, out);
|
|
95
|
+
}
|
|
96
|
+
onUpdate(end, ratio, out) {}
|
|
97
|
+
onEnd(cb) {
|
|
98
|
+
cb ? this._endCb = cb : this._endCb && (this.target.setAttributes(this.props), this._endCb(this.animate, this));
|
|
99
|
+
}
|
|
100
|
+
getEndProps() {
|
|
101
|
+
return this.props;
|
|
102
|
+
}
|
|
103
|
+
getFromProps() {
|
|
104
|
+
return this.fromProps;
|
|
105
|
+
}
|
|
106
|
+
getMergedEndProps() {
|
|
107
|
+
return this.getEndProps();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class WaitStep extends Step {
|
|
112
|
+
constructor(type, props, duration, easing) {
|
|
113
|
+
super(type, props, duration, easing);
|
|
114
|
+
}
|
|
115
|
+
update(end, ratio, out) {
|
|
116
|
+
this.onStart();
|
|
117
|
+
}
|
|
118
|
+
determineInterpolateUpdateFunction() {}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=step.js.map
|