Home Reference Source

Function

Static Public Summary
public

delay(ms: Number, args: ...): Promise

delays the call to nextFrame with setTimeout

public

frame(args: ...): Promise

create a Promise that resolves in the next Animationframe

public

create an animationframe loop that calls a function (callback) in every frame

public

nextFrame(args: ...): Promise

create a Promise that resolves in the next Animationframe

public

sequence(collection: Array, fn: Function): Promise

call a function sequencely every next frame on every iterating position of an array

public

throttle(cb: Function, frames: Number): Function

create a throttled animationframe loop that calls a function (callback) in every specified

public

until(fn: Function, args: ...): Promise

until fn returns a truthy value do not resolve.

public

wait(frame: Number, args: ...): Promise

waiting x frames before the Promise will resolve

public

when(fn: Function, args: ...): Promise

resolve when fn returns a truthy value.

Static Public

public delay(ms: Number, args: ...): Promise source

import delay from 'nextframe/src/delay.js'

delays the call to nextFrame with setTimeout

Params:

NameTypeAttributeDescription
ms Number

delay in ms

args ...

optional values that would be the params of the Promises resolve

Return:

Promise

which will resolve after the delayed animationframe

public frame(args: ...): Promise source

import frame from 'nextframe/src/frame.js'

create a Promise that resolves in the next Animationframe

Params:

NameTypeAttributeDescription
args ...

optional values that would be the params of the Promises resolve

Return:

Promise

which will resolve in the next Animationframe

public loop(cb: Function): Function source

import loop from 'nextframe/src/loop.js'

create an animationframe loop that calls a function (callback) in every frame

Params:

NameTypeAttributeDescription
cb Function

gets called in every frame - for rendering mostly

Return:

Function

a function which cancels the initialed loop by calling it

public nextFrame(args: ...): Promise source

import nextFrame from 'nextframe/src/nextframe.js'

create a Promise that resolves in the next Animationframe

Params:

NameTypeAttributeDescription
args ...

optional values that would be the params of the Promises resolve

Return:

Promise

which will resolve in the next Animationframe

public sequence(collection: Array, fn: Function): Promise source

import sequence from 'nextframe/src/sequence.js'

call a function sequencely every next frame on every iterating position of an array

Params:

NameTypeAttributeDescription
collection Array

keeps all values that will be used as the argument for the function

fn Function

will be called with array values as aruments

Return:

Promise

which will resolve after the sequence

public throttle(cb: Function, frames: Number): Function source

import throttle from 'nextframe/src/throttle.js'

create a throttled animationframe loop that calls a function (callback) in every specified

Params:

NameTypeAttributeDescription
cb Function

gets called in every specified frame

frames Number

throttle in wich interval cb is called

Return:

Function

a function which cancels the initialed loop by calling it

public until(fn: Function, args: ...): Promise source

import until from 'nextframe/src/until.js'

until fn returns a truthy value do not resolve.

Params:

NameTypeAttributeDescription
fn Function

a function that will be called every frame to check for changes

args ...

optional values that would be the params of the Promises resolve

Return:

Promise

which will resolve after the waiting frames

public wait(frame: Number, args: ...): Promise source

import wait from 'nextframe/src/wait.js'

waiting x frames before the Promise will resolve

Params:

NameTypeAttributeDescription
frame Number

the number of frames the Promise waits before resolving

args ...

optional values that would be the params of the Promises resolve

Return:

Promise

which will resolve after the waiting frames

public when(fn: Function, args: ...): Promise source

import when from 'nextframe/src/when.js'

resolve when fn returns a truthy value.

Params:

NameTypeAttributeDescription
fn Function

a function that will be called every frame to check for changes

args ...

optional values that would be the params of the Promises resolve

Return:

Promise

which will resolve after the waiting frames