1276N/A <p>This demonstrates how to use the <code>end</code> event.</p>
294N/A <p> Click the X in the header to fade the element out and remove it from the document once the fade completes.</p>
919N/A<h2>Setting up the HTML</h2>
919N/A<p>First we add some HTML to animate.</p>
919N/A<div id="demo" class="yui3-module">
919N/A <h3>Animation Demo</h3>
919N/A <a title="remove module" class="yui3-remove"><em>x</em></a>
919N/A <p>This an example of what you can do with the YUI Animation Utility.</p>
919N/A <p><em>Follow the instructions above to see the animation in action.</em></p>
294N/A<h2>Creating the Anim Instance</h2>
294N/A<p>Now we create an instance of <code>
Y.Anim</code>, passing it a configuration object that includes the <code>node</code> we wish to animate and the <code>to</code> attribute containing the properties to be transitioned and final values.</p>
1356N/A<h2>Handling the End Event</h2>
294N/A<p>We will need a function to run when the <code>end</code> event fires. Note that the context of our handler defaults to <code>anim</code>, so <code>this</code> refers to our Anim instance inside the handler.</p>
911N/Avar onEnd = function() {
1549N/A node.get('parentNode').removeChild(node); // node is an instance of Node
1276N/A<h2>Listening for the End Event</h2>
1276N/A<p>Now we will use the <code>on</code> method to subscribe to the <code>end</code> event, passing it our handler.</p>
970N/A<h2>Running the Animation</h2>
970N/A<p>Finally we add an event handler to run the animation.</p>
851N/A<h2>Complete Example Source</h2>