fatina
Version:
Lighweight Tweening Library for web / games
210 lines (209 loc) • 4.44 kB
TypeScript
import { Log } from '../core/enum/log';
import { State } from '../core/enum/state';
import { ISettings } from '../core/interfaces/ISettings';
import { ITicker } from '../core/interfaces/ITicker';
import { ITweenProperty } from '../core/interfaces/ITweenProperty';
/**
* Shared behaviors between different types of tweens and sequence
* Used mostly to manage:
* - events
* - state
* - loop and restart
*
* @export
* @abstract
* @class BaseTween
*/
export declare abstract class BaseTween<T extends BaseTween<any>> {
/**
* @protected
*/
protected events: {
[id: string]: any;
};
/**
* @inheritdoc
*/
elapsed: number;
/**
* @inheritdoc
*/
duration: number;
/**
* Timescale of the tween
* @type {number}
* @export
*/
timescale: number;
/**
* @inheritdoc
*/
state: State;
/**
* @protected
*/
protected loop: ITweenProperty | undefined;
/**
* @protected
*/
protected yo: ITweenProperty | undefined;
/**
* @protected
*/
protected parent: ITicker;
/**
* @protected
*/
protected tickCb: (dt: number) => void;
/**
* @private
*/
private first;
/**
* @private
*/
private settings?;
/**
* @inheritdoc
*/
get isIdle(): boolean;
/**
* @inheritdoc
*/
get isRunning(): boolean;
/**
* @inheritdoc
*/
get isFinished(): boolean;
/**
* @inheritdoc
*/
get isPaused(): boolean;
/**
* @inheritdoc
*/
start(): T;
/**
* @inheritdoc
* @readonly
*/
reset(skipParent?: boolean): void;
/**
* To immediately Reset a tween without stopping/restarting it
* This is faster than calling manually Reset() & Start() & Tick()
*
* @param {number} dtRemains
*/
resetAndStart(dtRemains: number): void;
/**
* @inheritdoc
*/
setParent(ticker: ITicker): T;
/**
* @inheritdoc
*/
setTimescale(scale: number): T;
/**
* @inheritdoc
*/
pause(): void;
/**
* @inheritdoc
*/
resume(): void;
/**
* @inheritdoc
*/
skip(finalValue?: boolean): void;
/**
* @inheritdoc
*/
kill(): void;
/**
* Method used to define how many time the tween has to loop
* Extra: if -1 the tween will loop forever
*
* @param {number} loop
* @returns {ITween}
*/
setLoop(loop: number): T;
setSettings(settings: ISettings): T;
/**
* @protected
*/
protected complete(): void;
/**
* @protected
*/
protected removeParent(): void;
/**
* @protected
*/
protected check(): void;
/**
* @protected
*/
protected validate(): void;
/**
* @protected
*/
protected loopInit(): void;
/**
* @protected
*/
protected info(level: Log, message: string, data?: any): void;
/**
* @private
*/
private emit;
/**
* @protected
*/
protected emitEvent(listeners: any, args?: any): void;
/**
* Callback called when the tween started
*
* @param {() => void} cb
* @returns {T}
*/
toPromise(): Promise<T>;
/**
* Callback called when the tween started
*
* @param {() => void} cb
* @returns {T}
*/
onStart(cb: () => void): T;
/**
* Callback called when the tween restart (loop)
*
* @param {() => void} cb
* @returns {T}
*/
onRestart(cb: () => void): T;
/**
* Callback called when the tween is updated
*
* @param {(dt: number, progress: number) => void} cb
* @returns {T}
*/
onUpdate(cb: (dt: number, progress: number) => void): T;
/**
* Callback called when the tween is manually killed
*
* @param {() => void} cb
* @returns {T}
*/
onKilled(cb: () => void): T;
/**
* Callback called when the tween is finished
*
* @param {() => void} cb
* @returns {T}
*/
onComplete(cb: () => void): T;
/**
* @protected
*/
protected onEvent(name: string, cb: any): T;
}