@visactor/vrender-core
Version:
```typescript import { xxx } from '@visactor/vrender-core'; ```
45 lines (44 loc) • 2.72 kB
TypeScript
import { AttributeUpdateType } from '../../common/enums';
import type { IAnimateConfig } from '../../interface/graphic';
export interface IStateTransitionPlan<T> {
targetAttrs: Partial<T>;
animateAttrs: Partial<T>;
noAnimateAttrs: Partial<T>;
}
export interface IStateTransitionAnalysisOptions {
noWorkAnimateAttr?: Record<string, number>;
isClear?: boolean;
getDefaultAttribute?: (key: string) => unknown;
shouldSkipDefaultAttribute?: (key: string, targetAttrs: Record<string, unknown>) => boolean;
animateConfig?: IAnimateConfig;
extraAnimateAttrs?: Record<string, unknown>;
}
export interface IStateTransitionApplyOptions {
animateConfig?: IAnimateConfig;
extraAnimateAttrs?: Record<string, unknown>;
shouldSkipDefaultAttribute?: (key: string, targetAttrs: Record<string, unknown>) => boolean;
}
export interface IStateTransitionGraphic<T> {
finalAttribute?: Record<string, any>;
applyAnimationState?: (state: string[], animations: Array<Record<string, any>>) => void;
setAttributesAndPreventAnimate: (attrs: Partial<T>, forceUpdateTag?: boolean, context?: {
type: AttributeUpdateType;
}) => void;
stopStateAnimates: () => void;
_emitCustomEvent: (type: string, context?: {
type: AttributeUpdateType;
}) => void;
getNoWorkAnimateAttr: () => Record<string, number>;
getDefaultAttribute: (key: string) => unknown;
shouldSkipStateTransitionDefaultAttribute: (key: string, targetAttrs?: Partial<T>) => boolean;
}
export interface IStateTransitionOrchestrator<T> {
analyzeTransition: (targetAttrs: Partial<T>, hasAnimation?: boolean, options?: IStateTransitionAnalysisOptions) => IStateTransitionPlan<T>;
applyTransition: (graphic: IStateTransitionGraphic<T>, plan: IStateTransitionPlan<T>, hasAnimation?: boolean, options?: IStateTransitionApplyOptions) => IStateTransitionPlan<T>;
applyClearTransition: (graphic: IStateTransitionGraphic<T>, targetAttrs: Partial<T>, hasAnimation?: boolean, options?: IStateTransitionApplyOptions) => IStateTransitionPlan<T>;
}
export declare class StateTransitionOrchestrator<T extends Record<string, any> = Record<string, any>> implements IStateTransitionOrchestrator<T> {
analyzeTransition(targetAttrs: Partial<T>, hasAnimation?: boolean, options?: IStateTransitionAnalysisOptions): IStateTransitionPlan<T>;
applyTransition(graphic: IStateTransitionGraphic<T>, plan: IStateTransitionPlan<T>, hasAnimation?: boolean, options?: IStateTransitionApplyOptions): IStateTransitionPlan<T>;
applyClearTransition(graphic: IStateTransitionGraphic<T>, targetAttrs: Partial<T>, hasAnimation?: boolean, options?: IStateTransitionApplyOptions): IStateTransitionPlan<T>;
}