Skip to content

Commit

Permalink
Merge pull request #18 from kefniark/develop
Browse files Browse the repository at this point in the history
Update Master - Fatina v1.0
  • Loading branch information
kefniark committed Feb 25, 2018
2 parents c1488e0 + 164151c commit 107e4d1
Show file tree
Hide file tree
Showing 28 changed files with 13,460 additions and 1,633 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ Small & Light tweening library for **Games** / **Web**

[![NPM Version](https://img.shields.io/npm/v/fatina.svg)](https://npmjs.org/package/fatina)
[![NPM Downloads](https://img.shields.io/npm/dm/fatina.svg)](https://npmjs.org/package/fatina)
[![Build Status](https://img.shields.io/travis/kefniark/Fatina.svg)](https://travis-ci.org/kefniark/Fatina)
[![Coverage Status](https://coveralls.io/repos/github/kefniark/Fatina/badge.svg?branch=develop)](https://coveralls.io/github/kefniark/Fatina?branch=develop)
[![Build Status](https://img.shields.io/travis/kefniark/Fatina/master.svg)](https://travis-ci.org/kefniark/Fatina)
[![Coverage Status](https://coveralls.io/repos/github/kefniark/Fatina/badge.svg?branch=master)](https://coveralls.io/github/kefniark/Fatina?branch=develop)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f0451df42a9d43fa810f32f20005f9aa)](https://www.codacy.com/app/kefniark/Fatina?utm_source=github.com&utm_medium=referral&utm_content=kefniark/Fatina&utm_campaign=Badge_Grade)
[![License](https://img.shields.io/npm/l/fatina.svg)](https://npmjs.org/package/fatina)

## Description
A comprehensive and easy to use animation library for **Typescript** / **Javascript**

* Easy to use (API strongly inspired by Dotween)
* Lightweight with no dependencies ( < 25KB )
* Lightweight with no dependencies ( < 20KB )
* Unit tested + code coverage
* Open source and MIT License (use it as you please)

Expand Down
114 changes: 106 additions & 8 deletions build/fatina.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function SetSafe(isSafe: boolean): void;
export function Destroy(): void;
export function Update(timestamp: number): any;
export function Tween(obj: any, properties: string[]): ITween;
export function Sequence(): ISequence;
export function Sequence(list?: tween[] | sequence[] | IPlayable[]): ISequence;
export function Delay(duration: number): IPlayable;
export function SetTimeout(fn: () => void, duration: number): IPlayable;
export function SetInterval(fn: () => void, duration: number): IPlayable;
Expand Down Expand Up @@ -50,8 +50,7 @@ export interface IPlayable extends IControl {
SetParent(ticker: ITicker): IPlayable;
Start(): IPlayable;
SetLoop(loop: number): IPlayable;
SetSafe(safe: boolean): IPlayable;
SetLog(level: Log): IPlayable;
SetSettings(settings: ISettings): IPlayable;
OnStart(cb: () => void): IPlayable;
OnRestart(cb: () => void): IPlayable;
OnUpdate(cb: (dt: number, progress: number) => void): IPlayable;
Expand All @@ -70,8 +69,7 @@ export interface ISequence extends IControl {
SetParent(ticker: ITicker): ISequence;
SetTimescale(scale: number): ISequence;
SetLoop(loop: number): ISequence;
SetSafe(safe: boolean): ISequence;
SetLog(level: Log): ISequence;
SetSettings(settings: ISettings): ISequence;
Append(tween: ITween | ISequence): ISequence;
AppendCallback(cb: () => void): ISequence;
AppendInterval(duration: number): ISequence;
Expand All @@ -91,7 +89,6 @@ export interface ISequence extends IControl {
export interface ITicker extends IControl {
AddTickListener(cb: (dt: number) => void): void;
RemoveTickListener(cb: (dt: number) => void): void;
CheckTickListener(cb: (dt: number) => void): boolean;
SetTimescale(scale: number): void;
}

Expand All @@ -110,8 +107,7 @@ export interface ITween extends IControl {
SetEasing(type: EasingType | string): ITween;
SetTimescale(scale: number): ITween;
ToSequence(): ISequence;
SetSafe(safe: boolean): ITween;
SetLog(level: Log): ITween;
SetSettings(settings: ISettings): ITween;
OnStart(cb: () => void): ITween;
OnUpdate(cb: (dt: number, progress: number) => void): ITween;
OnRestart(cb: () => void): ITween;
Expand Down Expand Up @@ -153,6 +149,44 @@ export enum EasingType {
InOutBounce = "inOutBounce",
}

export class Sequence extends BaseTween<Sequence> implements ISequence, ITicker, IPlayable {
currentTween: (ITween | IPlayable)[] | undefined;
readonly Count: number;
constructor(tweens?: ITween[] | ISequence[] | IPlayable[]);
protected LoopInit(): void;
AddTickListener(cb: (dt: number) => void): void;
RemoveTickListener(cb: (dt: number) => void): void;
Append(tween: ITween | ISequence): ISequence;
AppendCallback(cb: () => void): ISequence;
AppendInterval(duration: number): ISequence;
Prepend(tween: ITween | ISequence): ISequence;
PrependCallback(cb: () => void): ISequence;
PrependInterval(duration: number): ISequence;
Skip(finalValue?: boolean): void;
Kill(): void;
Join(tween: ITween | ISequence): ISequence;
OnStepStart(cb: (index: ITween | IPlayable) => void): ISequence;
OnStepEnd(cb: (index: ITween | IPlayable) => void): ISequence;
}

export class Tween extends BaseTween<Tween> implements ITween {
constructor(object: any, properties: string[]);
Init(object: any, properties: string[]): void;
protected Validate(): void;
protected CheckPosition(): void;
From(from: any): ITween;
To(to: any, duration: number): ITween;
SetRelative(relative: boolean): ITween;
Modify(diff: any, updateTo: boolean): void;
Reset(skipParent?: boolean): void;
Reverse(): void;
Yoyo(time: number): ITween;
SetSteps(steps: number): ITween;
ToSequence(): ISequence;
SetEasing(type: EasingType | string): ITween;
protected LoopInit(): void;
}

export enum State {
Idle = 0,
Run = 1,
Expand All @@ -161,3 +195,67 @@ export enum State {
Killed = 4,
}

export interface ISettings {
logLevel: Log;
safe: boolean;
}

export abstract class BaseTween<T extends BaseTween<any>> {
protected eventStart: {
(): void;
}[] | undefined;
protected eventRestart: {
(): void;
}[] | undefined;
protected eventUpdate: {
(dt: number, progress: number): void;
}[] | undefined;
protected eventKill: {
(): void;
}[] | undefined;
protected eventComplete: {
(): void;
}[] | undefined;
elapsed: number;
duration: number;
timescale: number;
state: State;
protected loop: ITweenProperty | undefined;
protected yoyo: ITweenProperty | undefined;
protected parent: ITicker;
protected tickCb: (dt: number) => void;
Start(): T;
Recycle(): void;
Reset(skipParent?: boolean): void;
ResetAndStart(dtRemains: number): void;
SetParent(ticker: ITicker): T;
SetTimescale(scale: number): T;
Pause(): void;
Resume(): void;
Skip(finalValue?: boolean): void;
Kill(): void;
SetLoop(loop: number): T;
SetSettings(settings: ISettings): T;
IsIdle(): boolean;
IsRunning(): boolean;
IsFinished(): boolean;
IsPaused(): boolean;
protected Complete(): void;
protected RemoveParentListener(): void;
protected CheckPosition(): void;
protected Validate(): void;
protected LoopInit(): void;
protected Info(level: Log, message: string, data?: any): void;
protected EmitEvent(listeners: any, args?: any): void;
OnStart(cb: () => void): T;
OnRestart(cb: () => void): T;
OnUpdate(cb: (dt: number, progress: number) => void): T;
OnKilled(cb: () => void): T;
OnComplete(cb: () => void): T;
}

export interface ITweenProperty {
original: number;
value: number;
}

Loading

0 comments on commit 107e4d1

Please sign in to comment.