UNPKG

web-ui-pack

Version:
24 lines (23 loc) 1.41 kB
declare global { namespace WUP { interface PromiseCancel<T> extends Promise<T> { /** Call it when you need to stop promise immediately; * @param isFinish finish promise immediately @defaultValue true * @tutorial * * isFinish:true - Promise is resolved with true & finish state * * isFinish:false - Promise is resolved with false & animation won't archive finish state * @returns promise resolved when animation stop process is done */ stop: (isFinish?: boolean) => Promise<T>; } } } /** Animation function based on window.requestAnimationFrame * @param from animate from value * @param to animate to value * @param ms time of animation * @param callback fired on every window.requestAnimationFrame() is fired * @param force set `true` to ignore window.matchMedia("(prefers-reduced-motion)") * @returns promise with extra functions; resolves `true` when animation is finished or resolves `false` when animation is canceled */ export default function animate(from: number, to: number, ms: number, callback: (v: number, ms: number, isLast: boolean, timeStamp: number) => void, force?: boolean): WUP.PromiseCancel<boolean>; /** Returns whether user don't 'prefers-reduced-motion' or do based on css-media `@media (prefers-reduced-motion)` */ export declare function isAnimEnabled(): boolean;