Tweenable

shifty Tweenable

new Tweenable(initialStateopt, configopt)

Implements:
  • Promise.<unknown>
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 Tweenable#tween or Tweenable#setConfig.

config shifty.tweenConfig <optional>

Configuration object to be passed to 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) → {Tweenable}

Tweenable#stops a tween and also rejects its external:Promise. If a tween is not running, this is a no-op. Prevents calling any provided finish function.

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

Is propagated to Tweenable#stop.

Returns:
Type:
Tweenable

catch(onRejected) → {Promise.<Object>}

Source:
See:
Parameters:
Name Type Description
onRejected function

Receives shifty.promisedData as the first parameter.

Returns:
Type:
Promise.<Object>

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 Tweenable instance is no longer needed to free memory.

Source:

finally(onFinally) → {Promise.<undefined>}

Source:
See:
Parameters:
Name Type Description
onFinally function
Returns:
Type:
Promise.<undefined>

get() → {Object}

Source:
Returns:
Type:
Object

The current state.

hasEnded() → {boolean}

Whether or not a tween has finished running.

Source:
Returns:
Type:
boolean

isPlaying() → {boolean}

Whether or not a tween is running.

Source:
Returns:
Type:
boolean

pause() → {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:
Tweenable

resume() → {Tweenable}

Resume a paused tween.

Source:
Returns:
Type:
Tweenable

seek(millisecond) → {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 number

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

Returns:
Type:
Tweenable

set(state)

Set the current state.

Source:
Parameters:
Name Type Description
state Object

The state to set.

setConfig(configopt) → {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 Tweenable instance.

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

setScheduleFunction(scheduleFunction)

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

stop(gotoEndopt) → {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 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:
Tweenable

then(onFulfilledopt, onRejectedopt) → {Promise.<Object>}

Overrides any finish function passed via a shifty.tweenConfig.

Source:
See:
Parameters:
Name Type Attributes Description
onFulfilled function <optional>

Receives shifty.promisedData as the first parameter.

onRejected function <optional>

Receives shifty.promisedData as the first parameter.

Returns:
Type:
Promise.<Object>

tween(configopt) → {Tweenable}

Configure and start a tween. If this 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 Tweenable#setConfig.

Returns:
Type:
Tweenable