API Documentation for: 0.6.0
Show:

SamplePlugin Class

Defined in: SamplePlugin:39
Module: TweenJS

A sample TweenJS plugin. This plugin does not actually affect tweens in any way, it's merely intended to document how to build TweenJS plugins. Please look at the code for inline comments.

A TweenJS plugin is simply an object that exposes one property (priority), and three methods (init, step, and tween). Generally a plugin will also expose an install method as well, though this is not strictly necessary.

Constructor

SamplePlugin

()

Defined in SamplePlugin:39

Item Index

Methods

Properties

Methods

init

(
  • tween
  • prop
  • value
)
Any static

Defined in init:72

Called by TweenJS when a new tween property initializes that this plugin is registered for. Generally, the call to Plugin.init will be immediately followed by a call to Plugin.to.

Parameters:

  • tween Tween

    The related tween instance.

  • prop String

    The name of the property that is being initialized.

  • value Any

    The current value of the property on the tween's target.

Returns:

Any:

The starting tween value for the property. In most cases, you would simply return the value parameter, but some plugins may need to modify the starting value.

init

(
  • tween
  • prop
  • startValue
  • injectProps
  • endValue
)
static

Defined in init:90

Called by TweenJS when a new step is added to a tween that includes a property the plugin is registered for (ie. a new "to" action is added to a tween).

Parameters:

  • tween Tween

    The related tween instance.

  • prop String

    The name of the property being tweened.

  • startValue Any

    The value of the property at the beginning of the step. This will be the same as the init value if this is the first step, or the same as the endValue of the previous step if not.

  • injectProps Object

    A generic object to which the plugin can append other properties which should be updated on this step.

  • endValue Any

    The value of the property at the end of the step.

install

() static

Defined in install:61

Installs this plugin for use with TweenJS, and registers for a list of properties that this plugin will operate with. Call this once after TweenJS is loaded to enable this plugin.

tween

(
  • tween
  • prop
  • value
  • startValues
  • endValues
  • ratio
  • wait
  • end
)
Any static

Defined in tween:107

Called when a tween property advances that this plugin is registered for.

Parameters:

  • tween Tween

    The related tween instance.

  • prop String

    The name of the property being tweened.

  • value Any

    The current tweened value of the property, as calculated by TweenJS.

  • startValues Object

    A hash of all of the property values at the start of the current step. You could access the start value of the current property using startValues[prop].

  • endValues Object

    A hash of all of the property values at the end of the current step.

  • ratio Number

    A value indicating the eased progress through the current step. This number is generally between 0 and 1, though some eases will generate values outside this range.

  • wait Boolean

    Indicates whether the current step is a "wait" step.

  • end Boolean

    Indicates that the tween has reached the end.

Returns:

Any:

Return the value that should be assigned to the target property. For example returning Math.round(value) would assign the default calculated value as an integer. Returning Tween.IGNORE will prevent Tween from assigning a value to the target property.

Properties

priority

Unknown static

Defined in priority:53

Used by TweenJS to determine when to call this plugin. Plugins with higher priority have their methods called before plugins with lower priority. The priority value can be any positive or negative number.