UNPKG

@drozdik.m/animation

Version:

Object for handling computed animations using lerp functions.

54 lines (53 loc) 1.61 kB
import { ILerpFunction } from "@drozdik.m/lerp"; import { Event } from "@drozdik.m/event"; import { AnimationArgs } from "../args/AnimationArgs"; export declare class Animation { private duration; private easing; private currentFrame; private fps; private frameTimeout; private from; private to; OnStart: Event<Animation, AnimationArgs>; OnRender: Event<Animation, AnimationArgs>; OnFrame: Event<Animation, AnimationArgs>; OnEnd: Event<Animation, AnimationArgs>; /** * Controller for handling lerp functions * @param from Value to animate from * @param to Value to animate to * @param duration Duration of the animation [ms] * @param easing Easing/lerp function */ constructor(duration?: number, easing?: ILerpFunction); /** * Invokes Stop and starts playing the animation * @param from Initial value * @param to Target value */ StopAndStart(from: number, to: number): Animation; /** * Plays an animation * @param from Initial value * @param to Target value */ Start(from: number, to: number): Animation; /** * Method that handles animation finishing * @param to Target value */ private FinishAnimation; /** * Stop and resets the current animation * */ Stop(): Animation; /** * Pauses the current animation * */ Pause(): Animation; /** * Continues last paused animation (only if previous animation were played) * */ Continue(): Animation; }