Skip to content

Latest commit

 

History

History
637 lines (493 loc) · 18.1 KB

API.md

File metadata and controls

637 lines (493 loc) · 18.1 KB

TWEEN : object

Lightweight, effecient and modular ES6 version of tween.js

Kind: global namespace
License: MIT
Copyright: 2017 @dalisoft and es6-tween contributors
Example

// ES6
const {add, remove, isRunning, autoPlay} = TWEEN

TWEEN.now ⇒

Get browser/Node.js current time-stamp

Kind: static property of TWEEN
Returns: Normalised current time-stamp in milliseconds
Example

TWEEN.now

TWEEN.Plugins : object

The plugins store object

Kind: static namespace of TWEEN
Example

let num = Plugins.num = function (node, start, end) {
return t => start + (end - start) * t
}

TWEEN.Easing : object

List of full easings

Kind: static namespace of TWEEN
Example

import {Tween, Easing} from 'es6-tween'

// then set via new Tween({x:0}).to({x:100}, 1000).easing(Easing.Quadratic.InOut).start()

TWEEN.Interpolation : object

List of full Interpolation

Kind: static namespace of TWEEN
Example

import {Interpolation, Tween} from 'es6-tween'

let bezier = Interpolation.Bezier
new Tween({x:0}).to({x:[0, 4, 8, 12, 15, 20, 30, 40, 20, 40, 10, 50]}, 1000).interpolation(bezier).start()

TWEEN.Interpolator ⇒ function

Tween helper for plugins

Kind: static namespace of TWEEN
Returns: function - Returns function that accepts number between 0-1

Param Type Description
a any Initial position
b any End position

TWEEN.Tween : object

Tween main constructor

Kind: static namespace of TWEEN

Param Type Description
node Object | Element Node Element or Tween initial object
[object] Object If Node Element is using, second argument is used for Tween initial object

Example

let tween = new Tween(myNode, {width:'100px'}).to({width:'300px'}, 2000).start()

Tween.Tween#setMaxListener(count)

Sets max event listener's count to Events system

Kind: static method of Tween

Param Type Description
count number Event listener's count

Tween.Tween#on(event, callback)

Adds event to Events system

Kind: static method of Tween

Param Type Description
event string Event listener name
callback function Event listener callback

Tween.Tween#once(event, callback)

Adds event to Events system. Removes itself after fired once

Kind: static method of Tween

Param Type Description
event string Event listener name
callback function Event listener callback

Tween.Tween#off(event, callback)

Removes event from Events system

Kind: static method of Tween

Param Type Description
event string Event listener name
callback function Event listener callback

Tween.Tween#emit(event)

Emits/Fired/Trigger event from Events system listeners

Kind: static method of Tween

Param Type Description
event string Event listener name

Tween.Tween#isPlaying() ⇒ boolean

Kind: static method of Tween
Returns: boolean - State of playing of tween
Example

tween.isPlaying() // returns `true` if tween in progress

Tween.Tween#isStarted() ⇒ boolean

Kind: static method of Tween
Returns: boolean - State of started of tween
Example

tween.isStarted() // returns `true` if tween in started

Tween.Tween#reverse([state])

Reverses the tween state/direction

Kind: static method of Tween

Param Type Description
[state] boolean Set state of current reverse

Example

tween.reverse()

Tween.Tween#reversed() ⇒ boolean

Kind: static method of Tween
Returns: boolean - State of reversed
Example

tween.reversed() // returns `true` if tween in reversed state

Tween.Tween#pause()

Pauses tween

Kind: static method of Tween
Example

tween.pause()

Tween.Tween#play()

Play/Resume the tween

Kind: static method of Tween
Example

tween.play()

Tween.Tween#restart([noDelay])

Restarts tween from initial value

Kind: static method of Tween

Param Type Description
[noDelay] boolean If this param is set to true, restarts tween without delay

Example

tween.restart()

Tween.Tween#seek(time, [keepPlaying])

Deprecated

Seek tween value by time. Note: Not works as excepted. PR are welcome

Kind: static method of Tween

Param Type Description
time Time Tween update time
[keepPlaying] boolean When this param is set to false, tween pausing after seek

Example

tween.seek(500)

Tween.Tween#duration(amount)

Sets tween duration

Kind: static method of Tween

Param Type Description
amount number Duration is milliseconds

Example

tween.duration(2000)

Tween.Tween#to(properties, [duration])

Sets target value and duration

Kind: static method of Tween

Param Type Default Description
properties object Target value (to value)
[duration] number | Object 1000 Duration of tween

Example

let tween = new Tween({x:0}).to({x:100}, 2000)

Tween.Tween#start(time)

Start the tweening

Kind: static method of Tween

Param Type Description
time number | string setting manual time instead of Current browser timestamp or like +1000 relative to current timestamp

Example

tween.start()

Tween.Tween#stop()

Stops the tween

Kind: static method of Tween
Example

tween.stop()

Tween.Tween#delay(amount)

Set delay of tween

Kind: static method of Tween

Param Type Description
amount number Sets tween delay / wait duration

Example

tween.delay(500)

Tween.Tween#chainedTweens(arguments)

Chained tweens

Kind: static method of Tween

Param Type Description
arguments any Arguments list

Example

tween.chainedTweens(tween1, tween2)

Tween.Tween#repeat(amount)

Sets how times tween is repeating

Kind: static method of Tween

Param Type Description
amount amount the times of repeat

Example

tween.repeat(5)

Tween.Tween#reverseDelay(amount)

Set delay of each repeat alternate of tween

Kind: static method of Tween

Param Type Description
amount number Sets tween repeat alternate delay / repeat alternate wait duration

Example

tween.reverseDelay(500)

Tween.Tween#yoyo(state, [_easingReverse])

Set yoyo state (enables reverse in repeat)

Kind: static method of Tween

Param Type Description
state boolean Enables alternate direction for repeat
[_easingReverse] function Easing function in reverse direction

Example

tween.yoyo(true)

Tween.Tween#easing(_easingFunction)

Set easing

Kind: static method of Tween

Param Type Description
_easingFunction function Easing function, applies in non-reverse direction if Tween#yoyo second argument is applied

Example

tween.easing(Easing.Elastic.InOut)

Tween.Tween#interpolation(_interpolationFunction)

Set interpolation

Kind: static method of Tween

Param Type Description
_interpolationFunction function Interpolation function

Example

tween.interpolation(Interpolation.Bezier)

Tween.Tween#update(time, [preserve], [forceTime])

Updates initial object to target value by given time

Kind: static method of Tween

Param Type Description
time Time Current time
[preserve] boolean Prevents from removing tween from store
[forceTime] boolean Forces to be frame rendered, even mismatching time

Example

tween.update(100)

TWEEN.add(tween)

Adds tween to list

Kind: static method of TWEEN

Param Type Description
tween Tween Tween instance

Example

let tween = new Tween({x:0})
tween.to({x:200}, 1000)
TWEEN.add(tween)

TWEEN.onTick(fn)

Adds ticker like event

Kind: static method of TWEEN

Param Type Description
fn function callback

Example

TWEEN.onTick(time => console.log(time))

TWEEN.FrameThrottle([frameCount])

Sets after how much frames empty updating should stop

Kind: static method of TWEEN

Param Type Default Description
[frameCount] number 120 count of frames that should stop after all tweens removed

Example

TWEEN.FrameThrottle(60)

TWEEN.autoPlay(state)

Runs update loop automaticlly

Kind: static method of TWEEN

Param Type Description
state Boolean State of auto-run of update loop

Example

TWEEN.autoPlay(true)

TWEEN.removeAll()

Removes all tweens from list

Kind: static method of TWEEN
Example

TWEEN.removeAll() // removes all tweens, stored in global tweens list

TWEEN.get(tween) ⇒ Tween

Kind: static method of TWEEN
Returns: Tween - Matched tween

Param Type Description
tween Tween Tween Instance to be matched

Example

TWEEN.get(tween)

TWEEN.has(tween) ⇒ Boolean

Kind: static method of TWEEN
Returns: Boolean - Status of Exists tween or not

Param Type Description
tween Tween Tween Instance to be matched

Example

TWEEN.has(tween)

TWEEN.remove(tween)

Removes tween from list

Kind: static method of TWEEN

Param Type Description
tween Tween Tween instance

Example

TWEEN.remove(tween)

TWEEN.update([time], [preserve])

Updates global tweens by given time

Kind: static method of TWEEN

Param Type Description
[time] number Timestamp
[preserve] Boolean Prevents tween to be removed after finish

Example

TWEEN.update(500)

TWEEN.isRunning() ⇒ Boolean

The state of ticker running

Kind: static method of TWEEN
Returns: Boolean - Status of running updates on all tweens
Example

TWEEN.isRunning()