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 |
config |
shifty.tweenConfig
|
<optional> |
Configuration object to be passed to
|
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:
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:
Type:
-
Object.<shifty.easingFunction>
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. |
cancel(gotoEndopt) → {Tweenable}
Tweenable#stop
s a tween and also reject
s its external:Promise
. If a tween is not running, this is a no-op. Prevents
calling any provided finish
function.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
gotoEnd |
boolean
|
<optional> |
Is propagated to |
Returns:
- Type:
-
Tweenable
catch(onRejected) → {Promise.<Object>}
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
onRejected |
function
|
Receives |
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>
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
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 |
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:
- Will be removed in favor of
Tweenable.setScheduleFunction
in 3.0.
- Will be removed in favor of
- 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 |
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 |
onRejected |
function
|
<optional> |
Receives |
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 |
Returns:
- Type:
-
Tweenable