UNPKG

@orca-fe/x-map

Version:
36 lines (35 loc) 1.49 kB
import { EventEmitter } from 'events'; declare type OnIntervalParams<T extends Record<string, number>> = (rate: number, state: T, linearRate: number) => void; declare type Easing = (num: number) => number; export declare function mix(start: number, end: number, rate: number): number; export declare function mixObj<T extends Record<string, number>>(start: T, end: Partial<T>, rate: number): T; export declare class Transition<T extends Record<string, number> = Record<string, number>> extends EventEmitter { protected _duration: number; protected fromState?: T; protected toState?: Partial<T>; protected easingFn: Easing; protected timer: number; protected rate: number; protected lastTime: number; running: boolean; construct(): void; duration: (duration: number) => this; easing: (easing: Easing) => this; from: (fromState: T) => this; to: (toState: Partial<T>) => this; onInterval: (callback: OnIntervalParams<T>) => this; offInterval: (callback: OnIntervalParams<T>) => this; start: () => this; resume: () => this; protected readonly run: () => void; cancel: () => void; stop: () => this; } export declare type TranstionOptions<T extends Record<string, number>> = { duration: number; from?: T; to?: Partial<T>; easing?: Easing; }; export default function transition<T extends Record<string, number>>(options: TranstionOptions<T>): Transition<T>; export {};