end-event.mustache revision 1f08a8488664773a7d96fa3a043a639692d2a5cb
e26236e4ee3c1c1cfed2f2c245cc9f2a8c7d4753Satyen Desai<link href="{{componentAssets}}/anim.css" rel="stylesheet" type="text/css">
e26236e4ee3c1c1cfed2f2c245cc9f2a8c7d4753Satyen Desai<div class="intro">
e26236e4ee3c1c1cfed2f2c245cc9f2a8c7d4753Satyen Desai <p>This demonstrates how to use the <code>end</code> event.</p>
e26236e4ee3c1c1cfed2f2c245cc9f2a8c7d4753Satyen Desai <p> Click the X in the header to fade the element out and remove it from the document once the fade completes.</p>
<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>
var anim = new Y.Anim({
<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>
var node = this.get('node'); // this === anim
node.get('parentNode').removeChild(node); // node is an instance of Node
<p>Now we will use the <code>on</code> method to subscribe to the <code>end</code> event, passing it our handler.</p>
anim.on('end', onEnd);