# Tweenable

## shifty. Tweenable

#### new Tweenable(initialStateopt, configopt)

Source:
  - tweenable.js, line 271

##### 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.filter`s available for use. These filters are automatically applied at tween-time by Shifty. You can define your own `shifty.filter`s and attach them to this object.

Source:
  - tweenable.js, line 633

##### Type:

- `Object.<shifty.filter>`

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

A static Object of `shifty.easingFunction`s that can by used by Shifty. The default values are defined in `easing-functions.js`, but you can add your own `shifty.easingFunction`s 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:
  - easing-functions.js, line 16

##### Type:

- `Object.<shifty.easingFunction>`

### Methods

#### (static) now() → {number}

Source:
  - tweenable.js, line 642

##### 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:
  - tweenable.js, line 616

##### 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#stop`s a tween and also `reject`s its `external:Promise`. If a tween is not running, this is a no-op.

Source:
  - tweenable.js, line 543
See:
  - https://github.com/jeremyckahn/shifty/issues/122

##### 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:
  - tweenable.js, line 588

##### 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:
  - tweenable.js, line 604

#### get() → {Object}

Source:
  - tweenable.js, line 390

##### Returns:

Type:
  `Object`

The current state.

#### isPlaying() → {boolean}

Whether or not a tween is running.

Source:
  - tweenable.js, line 570

##### 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:
  - tweenable.js, line 407

##### Returns:

Type:
  `shifty.Tweenable`

#### resume() → {external:Promise}

Resume a paused tween.

Source:
  - tweenable.js, line 425

##### 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:
  - tweenable.js, line 464

##### 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:
  - tweenable.js, line 398

##### 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:
  - tweenable.js, line 326

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`config` | `shifty.tweenConfig` | <optional> | {} |

##### Returns:

Type:
  `shifty.Tweenable`

#### setScheduleFunction(scheduleFunction)

Deprecated:
  - Will be removed in favor of `shifty.Tweenable.setScheduleFunction` in 3.0.
Source:
  - tweenable.js, line 579

##### 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:
  - tweenable.js, line 492

##### 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:
  - tweenable.js, line 300

##### 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.