|
0
|
1 |
|
|
|
2 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
|
3 |
<html> |
|
|
4 |
<head> |
|
|
5 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
6 |
<title>Reversing an Animation</title> |
|
|
7 |
|
|
|
8 |
<style type="text/css"> |
|
|
9 |
/*margin and padding on body element |
|
|
10 |
can introduce errors in determining |
|
|
11 |
element position and are not recommended; |
|
|
12 |
we turn them off as a foundation for YUI |
|
|
13 |
CSS treatments. */ |
|
|
14 |
body { |
|
|
15 |
margin:0; |
|
|
16 |
padding:0; |
|
|
17 |
} |
|
|
18 |
</style> |
|
|
19 |
|
|
|
20 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
21 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<!--begin custom header content for this example--> |
|
|
25 |
<link href="assets//anim.css" rel="stylesheet" type="text/css"> |
|
|
26 |
|
|
|
27 |
<!--end custom header content for this example--> |
|
|
28 |
|
|
|
29 |
</head> |
|
|
30 |
|
|
|
31 |
<body class=" yui-skin-sam"> |
|
|
32 |
|
|
|
33 |
<h1>Reversing an Animation</h1> |
|
|
34 |
|
|
|
35 |
<div class="exampleIntro"> |
|
|
36 |
<p>This demonstrates how to use the <code>reverse</code> attribute to change the behavior of the animation.</p> |
|
|
37 |
<p> Click the icon in the header to toggle the element's <code>height</code>.</p> |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
</div> |
|
|
41 |
|
|
|
42 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
<div id="demo" class="yui-module"> |
|
|
46 |
<div class="yui-hd"> |
|
|
47 |
<h4>Animation Demo</h4> |
|
|
48 |
</div> |
|
|
49 |
<div class="yui-bd"> |
|
|
50 |
<p>This an example of what you can do with the YUI Animation Utility.</p> |
|
|
51 |
<p><em>Follow the instructions above to see the animation in action.</em></p> |
|
|
52 |
</div> |
|
|
53 |
</div> |
|
|
54 |
<p>This is placeholder text used to demonstrate how the above animation affects subsequent content.</p> |
|
|
55 |
<script type="text/javascript"> |
|
|
56 |
YUI({base:"../../build/", timeout: 10000}).use("node", "anim", function(Y) { |
|
|
57 |
var module = Y.get('#demo'); |
|
|
58 |
|
|
|
59 |
// add fx plugin to module body |
|
|
60 |
var content = module.query('.yui-bd').plug(Y.Plugin.NodeFX, { |
|
|
61 |
from: { height: 1 }, |
|
|
62 |
to: { |
|
|
63 |
height: function(node) { // dynamic in case of change |
|
|
64 |
return node.get('scrollHeight'); // get expanded height (offsetHeight may be zero) |
|
|
65 |
} |
|
|
66 |
}, |
|
|
67 |
|
|
|
68 |
easing: Y.Easing.easeOut, |
|
|
69 |
duration: 0.5 |
|
|
70 |
}); |
|
|
71 |
|
|
|
72 |
var onClick = function(e) { |
|
|
73 |
module.toggleClass('yui-closed'); |
|
|
74 |
content.fx.set('reverse', !content.fx.get('reverse')); // toggle reverse |
|
|
75 |
content.fx.run(); |
|
|
76 |
}; |
|
|
77 |
|
|
|
78 |
// use dynamic control for dynamic behavior |
|
|
79 |
var control = Y.Node.create( |
|
|
80 |
'<a title="show/hide content" class="yui-toggle">' + |
|
|
81 |
'<em>toggle</em>' + |
|
|
82 |
'</a>' |
|
|
83 |
); |
|
|
84 |
|
|
|
85 |
// append dynamic control to header section |
|
|
86 |
module.query('.yui-hd').appendChild(control); |
|
|
87 |
control.on('click', onClick); |
|
|
88 |
|
|
|
89 |
}); |
|
|
90 |
|
|
|
91 |
</script> |
|
|
92 |
|
|
|
93 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
94 |
|
|
|
95 |
</body> |
|
|
96 |
</html> |