import { SelfEvent } from '../selfEvent'; import { requestAnimationFrame } from '../animationFrame'; import { EventType, Easing, Mode } from './constants'; export declare type Properties = { [x: string]: number; }; export declare type Handler = (params: { eventType?: EventType; currentValue: Properties; targetValue: Properties; initValue: Properties; }) => void; export interface AnimationOptions { duration?: number; easing?: Easing; mode?: Mode; } export declare const ModeTypes: { Linear: Mode; Quadratic: Mode; Cubic: Mode; Quartic: Mode; Quintic: Mode; Sinusoidal: Mode; Circular: Mode; Elastic: Mode; Back: Mode; Bounce: Mode; Exponential: Mode; }; export declare const EventTypes: { start: EventType; sleep: EventType; progress: EventType; complete: EventType; error: EventType; always: EventType; abort: EventType; }; export declare const EasingTypes: { easeIn: Easing; easeOut: Easing; easeInOut: Easing; }; export default class Animation { static defaultOptions: AnimationOptions; options: AnimationOptions; initProperties: Properties; nextProperties: Properties; targetProperties: Properties; selfEvent: SelfEvent; startTime: number; phase: string; runTime: number; animationTimer: ReturnType; sleepTimer: ReturnType; constructor(options?: AnimationOptions); private cancelTimer; /** * 任务回调 * @param eventType */ private emitSelfEvent; /** * 循环, 并触发回调 * @param tweenCallback */ private run; private progress; /** * 监听事件 * @param eventType * @param callback */ on: (eventType: EventType, callback: Handler) => void; /** * 开始动画 * @param initProperties * @param targetProperties * @param options */ start: (initProperties: Properties, targetProperties: Properties, options?: AnimationOptions) => void; /** * 延迟动画 * @param expire 单位ms */ sleep: (expire: number) => void; /** * 终止动画 */ abort: () => void; /** * 删除动画 */ cancel: () => void; }