The API is simple but very powerful, making it easy to create complex tweens by chaining commands.
var tween = createjsTween;
The example above will create a new tween instance that:
- tweens the target to an x value of 300 over 400ms and sets its label to "hello!"
- waits 500 ms
- tweens the target's alpha to 0 over 1s & sets its visible to false
- calls the onComplete function
Tweens are composed of two elements: steps and actions.
Steps define the tweened properties and always have a duration associated with them (even if that duration is 0). Steps are defined with the "to" and "wait" methods. Steps are entirely deterministic. You can arbitrarily set a tween's position, and it will always set the same properties for that position.
Actions do not have a duration, and are executed between steps. They are defined with the "call", "set", "play", and "pause" methods. They are guaranteed to execute in the correct order, but not at the precise moment in time that is indicated in the sequence. This can lead to indeterminate results, especially when tweens are interacting via the play and pause actions.
Tweens support a number of configuration properties, which are specified as the second param when creating a new tween:
All configuration properties default to false. The properties are:
- loop - indicates whether the tween should loop when it reaches the end
- useTicks - the tween will use ticks for duration instead of milliseconds
- css - enables css mapping for some css properties
- ignoreGlobalPause - the tween will continue ticking even when Ticker is paused.
When using Tween.get, you can also specify true as the third parameter to override any active tweens on the target.
createjsTween; // this will remove any existing tweens on the target.
Support and Resources
- Find examples and more information at the TweenJS web site
- Read the documentation
- Discuss, share projects, and interact with other users on reddit.
- Ask technical questions on Stack Overflow.
- File verified bugs or formal feature requests using Issues on GitHub.
- Have a look at the included examples and API documentation for more in-depth information.
It was built by gskinner.com, and is released for free under the MIT license, which means you can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a requirement.
Tween Returns a new Tween instance.
Timeline The Timeline class synchronizes multiple tweens and allows them to be controlled as a group.
Ease The Ease class provides a collection of easing functions for use with TweenJS. It does not use the standard 4 param easing signature. Instead it uses a single param which indicates the current linear ratio (0 to 1) of the tween.
Special thanks to Robert Penner for his easing equations, which form the basis for the Ease class.