easing.mustache revision 1f08a8488664773a7d96fa3a043a639692d2a5cb
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<link href="{{componentAssets}}/anim.css" rel="stylesheet" type="text/css">
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<div class="intro">
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <p>This demonstrates how to use the <code>easing</code> attribute to change the behavior of the animation.</p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <p> Click the icon in the header to shrink the element's <code>height</code> to zero with the "backIn" effect.</p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney</div>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<div class="example">
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney{{>easing-source}}
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney</div>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<h2>Setting up the HTML</h2>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<p>First we add some HTML to animate.</p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<div id="demo" class="yui3-module">
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <div class="yui3-hd">
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <h3>Animation Demo</h3>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <a title="remove module" class="yui3-toggle"><em>-</em></a>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney </div>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <div class="yui3-bd">
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <p>This an example of what you can do with the YUI Animation Utility.</p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney <p><em>Follow the instructions above to see the animation in action.</em></p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney </div>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney</div>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<h2>Creating the Anim Instance</h2>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<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 final properties and their values.</p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeneyvar anim = new Y.Anim({
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney node: '#demo .yui3-bd',
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney to: { height: 0 },
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney easing: 'backIn'
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney});
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<h2>Running the Animation</h2>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<p>Finally we add an event handler to run the animation.</p>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeneyvar onClick = function(e) {
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney e.preventDefault();
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney anim.run();
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney};
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt SweeneyY.one('#demo .yui3-toggle').on('click', onClick);
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney<h2>Complete Example Source</h2>
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney{{>easing-source}}
1f08a8488664773a7d96fa3a043a639692d2a5cbMatt Sweeney```