YUI 3: Animation
The Animation Utility provides an API for creating advanced transitions between property values.
More Information
- Examples: Animation Utility in action.
- API Documentation: View the full API documentation for the Animation Utility.
- Download: Animation Utility as part of the full YUI Library.
- Free Hosting on our fast edge servers with combo-loading.
- License: BSD.
Getting Started
Include Dependencies
To use the Animation Utility, include the YUI seed file:
Instantiating an Animation Object
Your Animation implementation will consist of one or more instances of the Anim.
To create an Anim instance on your page, pass it a configuration object including the node or selector query for the node that you wish to animate and a to containing the properties you wish to animate.
To begin the actual animation, call the run method on your Anim instance.
See the API documentation for the Anim object for more information about its methods and properties.
Using Animation
This section describes how to use the Animation utility in further detail. It contains these subsections:
Accessing Animation Attributes
In addition to passing a configuration object to the Anim constructor, you can access the attributes of your Anim instance via the set and get methods.
Setting a To Value
A node attribute and a to attribute containing one or more properties to animate are the minimum requirements for running an animation.
The value of a to can optionally be a function. If a function is used, it receives the node as its only argument. The return value of the function becomes the to value for that run of the animation.
Setting a From Value
Use the optional from attribute to start the animation from a specific value. When from is omitted, the current value is used.
Like the to attribute, the value of a from property can optionally be a function. If a function is used, it receives the node as its only argument. The return value of the function becomes the from value for that run of the animation.
Listening for Events
The Animation Utility defines events useful for hooking into the various stages of an animation. The on method is used to attach event listeners.
Support & Community
Forums & Blog
YUI 3 discussion forums are hosted on YUILibrary.com.
In addition, please visit the YUIBlog for updates and articles about the YUI Library written by the library's developers.
Filing Bugs & Feature Requests
The YUI Library's public bug tracking and feature request repositories are located on the YUILibrary.com site. Before filing new feature requests or bug reports, please review our reporting guidelines.

