onComplete
A common use case for animation involves causing two or more animations to fire sequentially. This is known as chaining. It's easy to chain animations using the YUI Animation Utility's custom events.
In this example, a color animation is set to fire after an animation of position. Click the button below to start the sequence.
Chaining animations is easy to achieve in YUI's Animation Utility using the custom events that are built into your Animation instances. Here, we'll use the onComplete
event of one animation to kick off a second animation, creating a simple chain.
This example has the following dependencies:
In this example, we begin with to page elements: a YUI Button that will actuate the animation sequence and a simple <div>
that will animate in position and then in color. Here's the markup for these elements:
With these two elements in place, we can write our script. This script:
#animator
is ready on the page;move
;changeColor
;animate()
method to the onComplete
event of the first animation to cause chaining;animate()
method to the button's click
event;Here is the full script block for this example:
You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.
Note: Logging and debugging is currently turned off for this example.
onComplete
Copyright © 2011 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings