@visactor/vrender-animate
Version:
This module provides a graph-based animation system for VRender.
76 lines (75 loc) • 3.26 kB
TypeScript
import type { IGraphic, EasingType } from '@visactor/vrender-core';
import type { ACustomAnimate } from '../custom/custom-animate';
export type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;
export type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;
interface IAnimationParameters {
[key: string]: any;
}
export type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;
export type IAnimationChannelAttrs = Record<string, {
from?: any | IAnimationChannelFunction;
to?: any | IAnimationChannelFunction;
}>;
export type IAnimationChannelAttributes = string[];
export type IAnimationChannelInterpolator = (ratio: number, from: any, to: any, nextAttributes: any, datum: any, element: IGraphic, parameters: IAnimationParameters) => boolean | void;
export interface IAnimationCustomConstructor {
new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;
}
export interface IAnimationEffect {
type?: string;
channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
to?: Record<string, any>;
from?: Record<string, any>;
custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
customParameters?: MarkFunctionValueType<any>;
easing?: EasingType;
options?: MarkFunctionValueType<any> | {
excludeChannels?: string[];
};
}
export interface IAnimationTimeSlice {
effects: IAnimationEffect | IAnimationEffect[];
duration?: MarkFunctionValueType<number>;
delay?: MarkFunctionValueType<number>;
delayAfter?: MarkFunctionValueType<number>;
}
export interface IAnimationControlOptions {
stopWhenStateChange?: boolean;
immediatelyApply?: boolean;
ignoreLoopFinalAttributes?: boolean;
}
export interface IAnimationTypeConfig {
type?: string;
channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
to?: Record<string, any>;
from?: Record<string, any>;
custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
customParameters?: MarkFunctionValueType<any>;
easing?: EasingType;
delay?: MarkFunctionValueType<number>;
delayAfter?: MarkFunctionValueType<number>;
duration?: MarkFunctionValueType<number>;
oneByOne?: MarkFunctionValueType<boolean | number>;
startTime?: MarkFunctionValueType<number>;
totalTime?: MarkFunctionValueType<number>;
loop?: boolean | number;
options?: MarkFunctionValueType<any>;
controlOptions?: IAnimationControlOptions;
priority?: number;
selfOnly?: boolean;
}
export interface IAnimationTimeline {
id?: string;
timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];
startTime?: MarkFunctionValueType<number>;
totalTime?: MarkFunctionValueType<number>;
oneByOne?: MarkFunctionValueType<number | boolean>;
loop?: MarkFunctionValueType<number | boolean>;
partitioner?: MarkFunctionCallback<boolean>;
sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;
controlOptions?: IAnimationControlOptions;
priority?: number;
selfOnly?: boolean;
}
export type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;
export {};