# Scene

## shifty. Scene

#### new Scene(…tweenables)

The `shifty.Scene` class provides a way to control groups of `shifty.Tweenable`s. It is lightweight, minimalistic, and meant to provide performant `shifty.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 `shifty.Scene` does not perform any automatic cleanup. If you want to remove a `shifty.Tweenable` from a `shifty.Scene`, you must do so explicitly with either `shifty.Scene#remove` or `shifty.Scene#empty`.

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

Source:
  - scene.js, line 30
See:
  - https://codepen.io/jeremyckahn/pen/qvZKbe

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`tweenables` | `shifty.Tweenable` | <repeatable> |

### Members

#### (readonly) promises :Array.<external:Promise>

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

    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:
  - scene.js, line 44

##### Type:

- `Array.<external:Promise>`

#### (readonly) tweenables :Array.<shifty.Tweenable>

A copy of the internal `shifty.Tweenable`s array.

Source:
  - scene.js, line 34

##### Type:

- `Array.<shifty.Tweenable>`

### Methods

#### add(tweenable) → {shifty.Tweenable}

Add a `shifty.Tweenable` to be controlled by this `shifty.Scene`.

Source:
  - scene.js, line 68

##### Parameters:

Name | Type | Description
--- | --- | ---
`tweenable` | `shifty.Tweenable` |

##### Returns:

Type:
  `shifty.Tweenable`

The `shifty.Tweenable` that was added.

#### empty() → {Array.<shifty.Tweenable>}

`Remove` all `shifty.Tweenable`s in this `shifty.Scene`.

Source:
  - scene.js, line 98

##### Returns:

Type:
  `Array.<shifty.Tweenable>`

The `shifty.Tweenable`s that were removed.

#### isPlaying() → {boolean}

Is `true` if any `shifty.Tweenable` in this `shifty.Scene` is playing.

Source:
  - scene.js, line 110

##### Returns:

Type:
  `boolean`

#### pause() → {shifty.Scene}

`shifty.Tweenable#pause` all `shifty.Tweenable`s in this `shifty.Scene`.

Source:
  - scene.js, line 131

##### Returns:

Type:
  `shifty.Scene`

#### play() → {shifty.Scene}

Play all `shifty.Tweenable`s from their beginning.

Source:
  - scene.js, line 120

##### Returns:

Type:
  `shifty.Scene`

#### remove(tweenable) → {shifty.Tweenable}

Remove a `shifty.Tweenable` that is controlled by this `shifty.Scene`.

Source:
  - scene.js, line 81

##### Parameters:

Name | Type | Description
--- | --- | ---
`tweenable` | `shifty.Tweenable` |

##### Returns:

Type:
  `shifty.Tweenable`

The `shifty.Tweenable` that was removed.

#### resume() → {shifty.Scene}

`shifty.Tweenable#resume` all paused `shifty.Tweenable`s.

Source:
  - scene.js, line 142

##### Returns:

Type:
  `shifty.Scene`

#### stop(gotoEndopt) → {shifty.Scene}

`shifty.Tweenable#stop` all `shifty.Tweenable`s in this `shifty.Scene`.

Source:
  - scene.js, line 153

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`gotoEnd` | `boolean` | <optional> |

##### Returns:

Type:
  `shifty.Scene`