import type { IAnimation } from '@antv/g';
import type { AnimationStage } from '../spec/element/animation';
import type { Element, ElementType, State } from '../types';
export type STDAnimation = AnimationOptions[];
/**
* 元素动画选项
*
* Element animation options
*/
export interface AnimationOptions extends AnimationEffectTiming {
/**
* 执行动画的字段(样式)名
*
* Field (style) name of the animation
*/
fields: string[];
/**
* 执行动画的图形,默认为当前元素
*
* Shape of the animation, default is the current element
*/
shape?: string;
/**
* 参与动画的状态
*
* States involved in the animation
*/
states?: State[];
}
export interface AnimationContext {
/**
* 执行动画的元素
*
* Element to execute animation
*/
element: Element;
/**
* 元素类型
*
* Element type
*/
elementType: ElementType;
/**
* 动画阶段
*
* Animation stage
*/
stage: AnimationStage;
/**
* 动画的源样式
*
* Source style of animation
* @remarks
* 用于在动画执行前将 shape 的样式设置为源样式,例如 move-to 动画,需要将 shape 的 x, y 设置为源样式
*
* Used to set the style of shape to the source style before the animation is executed. For example, the move-to animation needs to set the x and y of shape to the source style
*/
originalStyle: Record;
/**
* 额外的动画终态样式
*
* Additional animation final state style
* @remarks
* 例如元素销毁前,需要将元素的终态透明度设置为 0
*
* For example, before the element is destroyed, the final state opacity of the element needs to be set to 0
*/
modifiedStyle?: Record;
/**
* 变更样式
*
* Updated style
*/
updatedStyle?: Record;
}
/**
* 动画效果时序
*
* Animation effect timing
*/
export interface AnimationEffectTiming {
/**
* 动画延迟时间
*
* Animation delay time
*/
delay?: number;
/**
* 动画方向
*
* Animation direction
*/
direction?: PlaybackDirection;
/**
* 动画持续时间
*
* Animation duration
*/
duration?: number;
/**
* 动画缓动函数
*
* Animation easing function
*/
easing?: string;
/**
* 动画结束后的填充模式
*
* Fill mode after the animation ends
*/
fill?: FillMode;
/**
* 动画迭代次数
*
* Number of iterations of the animation
*/
iterations?: number;
}
export type AnimationExecutor = (element: Element, keyframes: [Record, Record], options: STDAnimation) => IAnimation | null;