Tweenable

shifty. Tweenable

new Tweenable(initialStateopt, configopt)

Source:
Parameters:
Name Type Attributes Default Description
initialState Object <optional>
{}

The values that the initial tween should start at if a from value is not provided to shifty.Tweenable#tween or shifty.Tweenable#setConfig.

config shifty.tweenConfig <optional>

Configuration object to be passed to shifty.Tweenable#setConfig.

Members

(static) filters :Object.<shifty.filter>

The shifty.filters available for use. These filters are automatically applied at tween-time by Shifty. You can define your own shifty.filters and attach them to this object.

Source:
Type:

(static) formulas :Object.<shifty.easingFunction>

A static Object of shifty.easingFunctions that can by used by Shifty. The default values are defined in easing-functions.js, but you can add your own shifty.easingFunctions by defining them as keys to this Object.

Shifty ships with an implementation of Robert Penner's easing equations, as adapted from Scripty2's implementation.

See the Pen Shifty - Easing formula names by Jeremy Kahn (@jeremyckahn) on CodePen.

Source:
Type:

Methods

(static) now() → {number}

Source:
Returns:
Type:
number

The current timestamp.

(static) setScheduleFunction(fn) → {shifty.scheduleFunction}

Set a custom schedule function.

By default, requestAnimationFrame is used if available, otherwise setTimeout is used.

Source:
Parameters:
Name Type Description
fn shifty.scheduleFunction

The function to be used to schedule the next frame to be rendered.

Returns:
Type:
shifty.scheduleFunction

The function that was set.

cancel(gotoEndopt) → {shifty.Tweenable}

shifty.Tweenable#stops a tween and also rejects its external:Promise. If a tween is not running, this is a no-op.

Source:
See:
Parameters:
Name Type Attributes Description
gotoEnd boolean <optional>

Is propagated to shifty.Tweenable#stop.

Returns:
Type:
shifty.Tweenable

data(dataopt) → {Object}

Get and optionally set the data that gets passed as data to shifty.promisedData, shifty.startFunction and shifty.renderFunction.

Source:
Parameters:
Name Type Attributes Description
data Object <optional>
Returns:
Type:
Object

The internally stored data.

dispose()

delete all "own" properties. Call this when the shifty.Tweenable instance is no longer needed to free memory.

Source:

get() → {Object}

Source:
Returns:
Type:
Object

The current state.

isPlaying() → {boolean}

Whether or not a tween is running.

Source:
Returns:
Type:
boolean

pause() → {shifty.Tweenable}

Pause a tween. Paused tweens can be resumed from the point at which they were paused. If a tween is not running, this is a no-op.

Source:
Returns:
Type:
shifty.Tweenable

resume() → {external:Promise}

Resume a paused tween.

Source:
Returns:
Type:
external:Promise

seek(millisecond) → {shifty.Tweenable}

Move the state of the animation to a specific point in the tween's timeline. If the animation is not running, this will cause shifty.renderFunction handlers to be called.

Source:
Parameters:
Name Type Description
millisecond millisecond

The millisecond of the animation to seek to. This must not be less than 0.

Returns:
Type:
shifty.Tweenable

set(state)

Set the current state.

Source:
Parameters:
Name Type Description
state Object

The state to set.

setConfig(configopt) → {shifty.Tweenable}

Configure a tween that will start at some point in the future. Aside from delay, from, and to, each configuration option will automatically default to the same option used in the preceding tween of this shifty.Tweenable instance.

Source:
Parameters:
Name Type Attributes Default Description
config shifty.tweenConfig <optional>
{}
Returns:
Type:
shifty.Tweenable

setScheduleFunction(scheduleFunction)

Deprecated:
Source:
Parameters:
Name Type Description
scheduleFunction shifty.scheduleFunction

stop(gotoEndopt) → {shifty.Tweenable}

Stops a tween. If a tween is not running, this is a no-op. This method does not cancel the tween external:Promise. For that, use shifty.Tweenable#cancel.

Source:
Parameters:
Name Type Attributes Description
gotoEnd boolean <optional>

If false, the tween just stops at its current state. If true, the tweened object's values are instantly set to the target values.

Returns:
Type:
shifty.Tweenable

tween(configopt) → {external:Promise}

Configure and start a tween. If this shifty.Tweenable's instance is already running, then it will stop playing the old tween and immediately play the new one.

Source:
Parameters:
Name Type Attributes Description
config shifty.tweenConfig <optional>

Gets passed to shifty.Tweenable#setConfig.

Returns:
Type:
external:Promise

This Promise resolves with a shifty.promisedData object.