|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Basic Node Transitions</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<h1>Example: Basic Node Transitions</h1> |
|
|
25 |
<div class="yui3-g"> |
|
|
26 |
<div class="yui3-u-3-4"> |
|
|
27 |
<div id="main"> |
|
|
28 |
<div class="content"><link href="../assets/transition/transition.css" rel="stylesheet" type="text/css"> |
|
|
29 |
<div class="intro"> |
|
|
30 |
<p>The <code>transition</code> method animates the value of each property from the current value to the given value. |
|
|
31 |
Click the X to run the animation.</p> |
|
|
32 |
</div> |
|
|
33 |
|
|
|
34 |
<div class="example"> |
|
|
35 |
<div id="demo"> |
|
|
36 |
<a href="#" title="run the animation"></a> |
|
|
37 |
</div> |
|
|
38 |
|
|
|
39 |
<script type="text/javascript"> |
|
|
40 |
YUI().use('transition', function(Y) { |
|
|
41 |
var node = Y.one('#demo'); |
|
|
42 |
|
|
|
43 |
node.one('a').on('click', function(e) { |
|
|
44 |
e.preventDefault(); |
|
|
45 |
|
|
|
46 |
node.transition({ |
|
|
47 |
duration: 1, // seconds |
|
|
48 |
easing: 'ease-out', |
|
|
49 |
height: 0, |
|
|
50 |
width: 0, |
|
|
51 |
left: '150px', |
|
|
52 |
top: '100px', |
|
|
53 |
opacity: 0 |
|
|
54 |
}, function() { |
|
|
55 |
this.remove(); |
|
|
56 |
}); |
|
|
57 |
}); |
|
|
58 |
}); |
|
|
59 |
</script> |
|
|
60 |
|
|
|
61 |
</div> |
|
|
62 |
|
|
|
63 |
<h2>Using the Transition Method</h2> |
|
|
64 |
<p>Transition allows you to animate one or more properties from their current value to a given value with the specified duration and easing method.</p> |
|
|
65 |
|
|
|
66 |
<pre class="code prettyprint">Y.one('#demo').transition({ |
|
|
67 |
duration: 1, // seconds |
|
|
68 |
easing: 'ease-out', |
|
|
69 |
height: 0, |
|
|
70 |
width: 0, |
|
|
71 |
left: '150px', |
|
|
72 |
top: '100px', |
|
|
73 |
opacity: 0 |
|
|
74 |
});</pre> |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
<h2>Transition with Callback</h2> |
|
|
78 |
<p>The <code>transition</code> method provides an optional callback argument, which is a function that runs once the transition is completed. The callback runs only for this transition.</p> |
|
|
79 |
|
|
|
80 |
<pre class="code prettyprint">var node = Y.one('#demo'); |
|
|
81 |
|
|
|
82 |
node.transition({ |
|
|
83 |
duration: 1, // seconds |
|
|
84 |
easing: 'ease-out', |
|
|
85 |
height: 0, |
|
|
86 |
width: 0, |
|
|
87 |
left: '150px', |
|
|
88 |
top: '100px', |
|
|
89 |
opacity: 0 |
|
|
90 |
}, function() { |
|
|
91 |
this.remove(); |
|
|
92 |
});</pre> |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
<h2>Complete Example Source</h2> |
|
|
96 |
<pre class="code prettyprint"><div id="demo"> |
|
|
97 |
<a href="#" title="run the animation"></a> |
|
|
98 |
</div> |
|
|
99 |
|
|
|
100 |
<script type="text/javascript"> |
|
|
101 |
YUI().use('transition', function(Y) { |
|
|
102 |
var node = Y.one('#demo'); |
|
|
103 |
|
|
|
104 |
node.one('a').on('click', function(e) { |
|
|
105 |
e.preventDefault(); |
|
|
106 |
|
|
|
107 |
node.transition({ |
|
|
108 |
duration: 1, // seconds |
|
|
109 |
easing: 'ease-out', |
|
|
110 |
height: 0, |
|
|
111 |
width: 0, |
|
|
112 |
left: '150px', |
|
|
113 |
top: '100px', |
|
|
114 |
opacity: 0 |
|
|
115 |
}, function() { |
|
|
116 |
this.remove(); |
|
|
117 |
}); |
|
|
118 |
}); |
|
|
119 |
}); |
|
|
120 |
</script></pre> |
|
|
121 |
|
|
|
122 |
</div> |
|
|
123 |
</div> |
|
|
124 |
</div> |
|
|
125 |
|
|
|
126 |
<div class="yui3-u-1-4"> |
|
|
127 |
<div class="sidebar"> |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
<div class="sidebox"> |
|
|
132 |
<div class="hd"> |
|
|
133 |
<h2 class="no-toc">Examples</h2> |
|
|
134 |
</div> |
|
|
135 |
|
|
|
136 |
<div class="bd"> |
|
|
137 |
<ul class="examples"> |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
<li data-description="Demonstrates the basic usage of Transitions."> |
|
|
141 |
<a href="transition-basic.html">Basic Node Transitions</a> |
|
|
142 |
</li> |
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
<li data-description="Demonstrates more advanced usage of Transitions."> |
|
|
147 |
<a href="transition-usage.html">Using Transitions</a> |
|
|
148 |
</li> |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
<li data-description="Demonstrates how to animate Node's show and hide methods."> |
|
|
153 |
<a href="transition-view.html">Showing and Hiding with Transitions</a> |
|
|
154 |
</li> |
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
</ul> |
|
|
172 |
</div> |
|
|
173 |
</div> |
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
<div class="sidebox"> |
|
|
178 |
<div class="hd"> |
|
|
179 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
180 |
</div> |
|
|
181 |
|
|
|
182 |
<div class="bd"> |
|
|
183 |
<ul class="examples"> |
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
<li data-description="Shows how to create a panel that animates as it is shown and hidden"> |
|
|
193 |
<a href="../panel/panel-animate.html">Creating an Animated Panel</a> |
|
|
194 |
</li> |
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
<li data-description="This example employs AsyncQueue to incrementally construct an application interface; this illustrates the approach you'd take to allow chunked rendering of the UI in a process-intensive application."> |
|
|
199 |
<a href="../async-queue/queue-app.html">Building a UI with AsyncQueue</a> |
|
|
200 |
</li> |
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
<li data-description="Extend the Promise class to create your own Node plugin that chains transitions"> |
|
|
205 |
<a href="../promise/plugin-example.html">Creating a Node Plugin that chains transitions</a> |
|
|
206 |
</li> |
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
<li data-description="Create a reusable JSONPRequest object to poll the YUILibrary.com Gallery web service, fetching info on a random Gallery module."> |
|
|
211 |
<a href="../jsonp/jsonp-gallery.html">Reusing a JSONPRequest Instance to Poll a Remote Server</a> |
|
|
212 |
</li> |
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
<li data-description="NodeList provides Node functionality for manipulating multiple nodes at once."> |
|
|
217 |
<a href="../node/nodelist.html">Using NodeList - Simple</a> |
|
|
218 |
</li> |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
<li data-description="How to use multiple NodeList features to build a simple game."> |
|
|
223 |
<a href="../node/ducks.html">Using NodeList - Ducks Game</a> |
|
|
224 |
</li> |
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
<li data-description="This example demonstrates how to insert content into a Node."> |
|
|
229 |
<a href="../node/node-insert.html">Adding Node Content - Burger Builder</a> |
|
|
230 |
</li> |
|
|
231 |
|
|
|
232 |
|
|
|
233 |
</ul> |
|
|
234 |
</div> |
|
|
235 |
</div> |
|
|
236 |
|
|
|
237 |
</div> |
|
|
238 |
</div> |
|
|
239 |
</div> |
|
|
240 |
</div> |
|
|
241 |
|
|
|
242 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
243 |
<script>prettyPrint();</script> |
|
|
244 |
|
|
|
245 |
<script> |
|
|
246 |
YUI.Env.Tests = { |
|
|
247 |
examples: [], |
|
|
248 |
project: '../assets', |
|
|
249 |
assets: '../assets/transition', |
|
|
250 |
name: 'transition-basic', |
|
|
251 |
title: 'Basic Node Transitions', |
|
|
252 |
newWindow: '', |
|
|
253 |
auto: false |
|
|
254 |
}; |
|
|
255 |
YUI.Env.Tests.examples.push('transition-basic'); |
|
|
256 |
YUI.Env.Tests.examples.push('transition-usage'); |
|
|
257 |
YUI.Env.Tests.examples.push('transition-view'); |
|
|
258 |
YUI.Env.Tests.examples.push('panel-animate'); |
|
|
259 |
YUI.Env.Tests.examples.push('queue-app'); |
|
|
260 |
YUI.Env.Tests.examples.push('plugin-example'); |
|
|
261 |
YUI.Env.Tests.examples.push('jsonp-gallery'); |
|
|
262 |
YUI.Env.Tests.examples.push('nodelist'); |
|
|
263 |
YUI.Env.Tests.examples.push('ducks'); |
|
|
264 |
YUI.Env.Tests.examples.push('node-insert'); |
|
|
265 |
|
|
|
266 |
</script> |
|
|
267 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
</body> |
|
|
272 |
</html> |