YUI recommends YUI3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

This documentation is no longer maintained.

YUI Library Examples: Animation Utility: Basic Animation

Animation Utility: Basic Animation

This demonstrates how to apply a simple animation effect to an HTMLElement. Click the button to begin the demo.

Demo

Creating a Simple Animation

The YUI Animation Utility makes adding animation effects to HTMLElements easy.

For this example, we will animate the width of the <div> element named demo.

Add a little style so that we can see the animation in action:

Create the demo element and a button to run the animation:

Now we create an instance of YAHOO.util.Anim, passing it the element we wish to animate, and the style attribute(s) to be animated. Each attribute requires at least a to by field, which will be used as the ending value. A from field is optional; if omitted the animation starts from its current value.

The final step is to call the animate method on our instance to start the animation. The button will be the trigger that begins the animation sequence:

This is a basic example of the YUI Animation Utility.

Copyright © 2013 Yahoo! Inc. All rights reserved.

Privacy Policy - Copyright Policy - Job Openings