<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Reversing an Animation</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>
<!--begin custom header content for this example-->
<link href="assets//anim.css" rel="stylesheet" type="text/css">
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Reversing an Animation</h1>
<div class="exampleIntro">
<p>This demonstrates how to use the <code>reverse</code> attribute to change the behavior of the animation.</p>
<p> Click the icon in the header to toggle the element's <code>height</code>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
<div id="demo" class="yui-module">
<div class="yui-hd">
<h4>Animation Demo</h4>
</div>
<div class="yui-bd">
<p>This an example of what you can do with the YUI Animation Utility.</p>
<p><em>Follow the instructions above to see the animation in action.</em></p>
</div>
</div>
<p>This is placeholder text used to demonstrate how the above animation affects subsequent content.</p>
<script type="text/javascript">
YUI({base:"../../build/", timeout: 10000}).use("node", "anim", function(Y) {
var module = Y.get('#demo');
// add fx plugin to module body
var content = module.query('.yui-bd').plug(Y.Plugin.NodeFX, {
from: { height: 1 },
to: {
height: function(node) { // dynamic in case of change
return node.get('scrollHeight'); // get expanded height (offsetHeight may be zero)
}
},
easing: Y.Easing.easeOut,
duration: 0.5
});
var onClick = function(e) {
module.toggleClass('yui-closed');
content.fx.set('reverse', !content.fx.get('reverse')); // toggle reverse
content.fx.run();
};
// use dynamic control for dynamic behavior
var control = Y.Node.create(
'<a title="show/hide content" class="yui-toggle">' +
'<em>toggle</em>' +
'</a>'
);
// append dynamic control to header section
module.query('.yui-hd').appendChild(control);
control.on('click', onClick);
});
</script>
<!--END SOURCE CODE FOR EXAMPLE =============================== -->
</body>
</html>