Scene

shifty Scene

new Scene(…tweenables)

The Scene class provides a way to control groups of Tweenables. It is lightweight, minimalistic, and meant to provide performant Tweenable batch control that users of Shifty might otherwise have to implement themselves. It is not a robust timeline solution, and it does not provide utilities for sophisticated animation sequencing or orchestration. If that is what you need for your project, consider using a more robust tool such as Rekapi (a timeline layer built on top of Shifty).

Please be aware that Scene does not perform any automatic cleanup. If you want to remove a Tweenable from a Scene, you must do so explicitly with either Scene#remove or Scene#empty.

See the Pen Shifty Scene Demo by Jeremy Kahn (@jeremyckahn) on CodePen.

Source:
See:
Parameters:
Name Type Attributes Description
tweenables Tweenable <repeatable>

Members

playingTweenables :Array.<Tweenable>

A list of Tweenables in the scene that have not yet ended (playing or not).

Source:
Type:

promises :Array.<Promise.<any>>

The external:Promises for all Tweenables in this Scene that have been configured with Tweenable#setConfig. Note that each call of Scene#play or Scene#pause creates new external:Promises:

const scene = new Scene(new Tweenable());
scene.play();

Promise.all(scene.promises).then(() =>
  // Plays the scene again upon completion, but a new promise is
  // created so this line only runs once.
  scene.play()
);
Source:
Type:
  • Array.<Promise.<any>>

tweenables :Array.<Tweenable>

A copy of the internal Tweenables array.

Source:
Type:

Methods

add(tweenable) → {Tweenable}

Add a Tweenable to be controlled by this Scene.

Source:
Parameters:
Name Type Description
tweenable Tweenable
Returns:
Type:
Tweenable

The Tweenable that was added.

empty() → {Array.<Tweenable>}

Remove all Tweenables in this Scene.

Source:
Returns:
Type:
Array.<Tweenable>

The Tweenables that were removed.

isPlaying() → {boolean}

Is true if any Tweenable in this Scene is playing.

Source:
Returns:
Type:
boolean

pause() → {Scene}

Source:
Returns:
Type:
Scene

play() → {Scene}

Play all Tweenables from their beginning.

Source:
Returns:
Type:
Scene

remove(tweenable) → {Tweenable}

Remove a Tweenable that is controlled by this Scene.

Source:
Parameters:
Name Type Description
tweenable Tweenable
Returns:
Type:
Tweenable

The Tweenable that was removed.

resume() → {Scene}

Source:
Returns:
Type:
Scene

stop(gotoEndopt) → {Scene}

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