source: cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/examples/anim/alt-iterations.html @ 5259

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/examples/anim/alt-iterations.html@5259
Revision 5259, 13.7 KB checked in by domlowe, 11 years ago (diff)

adding yui javascript

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4        <title>YUI Library Examples: Animation Utility: Alternating Iterations</title>
5    <meta http-equiv="content-type" content="text/html; charset=utf-8">
6        <link rel="stylesheet" type="text/css" href="../../assets/yui.css" >
7
8<style>
9    /*Supplemental CSS for the YUI distribution*/
10    #custom-doc { width: 95%; min-width: 950px; }
11    #pagetitle {background-image: url(../../assets/bg_hd.gif);}
12    #pagetitle h1 {background-image: url(../../assets/title_h_bg.gif);}
13</style>
14
15<link rel="stylesheet" type="text/css" href="../../assets/dpSyntaxHighlighter.css">
16<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
17<script type="text/javascript" src="../../build/yui/yui-min.js"></script>
18<link href="assets//anim.css" rel="stylesheet" type="text/css">
19
20</head>
21<body id="yahoo-com" class=" yui-skin-sam">
22<div id="custom-doc" class="yui-t2">
23<div id="hd">
24        <div id="ygunav">
25                <p>
26            <em>
27                <a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> 
28            </em>
29                </p>
30                <form action="http://search.yahoo.com/search" id="sitesearchform">
31            <input name="vs" type="hidden" value="developer.yahoo.com">
32            <input name="vs" type="hidden" value="yuiblog.com">
33                    <div id="sitesearch">
34                        <label for="searchinput">Site Search (YDN &amp; YUIBlog): </label>
35                            <input type="text" id="searchinput" name="p">
36                            <input type="submit" value="Search" id="searchsubmit" class="ygbt">
37                    </div>
38                </form>
39    </div>
40        <div id="ygma"><a href="../../"><img src="../../assets/logo.gif"  border="0" width="200" height="93"></a></div>
41        <div id="pagetitle"><h1>YUI Library Examples: Animation Utility: Alternating Iterations</h1></div>
42</div>
43<div id="bd">
44
45        <div id="bar-note"><p><strong>Note:</strong> This is YUI 3.x. Looking for <a href="http://developer.yahoo.com/yui/">YUI 2.x</a>?</p></div>
46
47        <div id="yui-main">
48                <div class="yui-b">
49                  <div class="yui-ge">
50                          <div class="yui-u first example" id="main">
51
52        <h2>Animation Utility: Alternating Iterations</h2>
53
54        <div id="example" class="promo">
55        <p>
56        <p>This demonstrates how to use the <code>iterations</code> attribute to run multiple iterations of the animation.</p>
57<p>Mouse over the link to begin the animation.</p>
58
59        </p>   
60
61        <div class="module example-container ">
62                        <div class="hd exampleHd">
63                        <p class="newWindowButton yui-skin-sam">
64                <a href="alt-iterations_clean.html" target="_blank">View example in new window.</a>
65            </p>
66                </div>          <div id="example-canvas" class="bd">
67
68               
69        <!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
70       
71           
72<a href="#" id="demo">hover me</a>
73<script type="text/javascript">
74YUI({base:"../../build/", timeout: 10000}).use("anim-color", function(Y) {
75    var node = Y.get('#demo');
76
77    var anim = new Y.Anim({
78        node: node,
79        from: {
80            backgroundColor:node.getStyle('backgroundColor'),
81            color: node.getStyle('color'),
82            borderColor: node.getStyle('borderTopColor')
83        },
84
85        to: {
86            color: '#fff',
87            backgroundColor:'#ffa928',
88            borderColor: '#71241a'
89        },
90
91        duration: 0.5,
92        iterations: 'infinite',
93        direction: 'alternate'
94    });
95
96    var hover = function(e) {
97        var reverse = false,
98            iterations = 'infinite';
99
100        if (anim.get('running')) {
101            anim.pause();
102        }
103        if (e.type === 'mouseout') {
104            reverse = true;
105            iterations = 1;
106        }
107        anim.setAtts({
108            'reverse': reverse,
109            'iterations': iterations
110        });
111
112        anim.run();
113    };
114
115    node.on('mouseover', hover);
116    node.on('mouseout', hover);
117});
118
119</script>
120       
121        <!--END SOURCE CODE FOR EXAMPLE =============================== -->
122       
123               
124                </div>
125        </div>                 
126        </div>
127               
128        <h3>Setting up the HTML</h3>
129<p>First we add some HTML to animate.</p>
130<textarea name="code" class="JScript" cols="60" rows="1">
131<a href="#" id="demo">hover me</a>
132</textarea>
133
134<h3>Creating the Anim Instance</h3>
135<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>
136<p>Adding an <code>iterations</code> attribute of "infinite" means that the animation will run continuously.</p>
137<p>The <code>direction</code> attribute of "alternate" means that the animation reverses every other iteration.</p>
138
139<textarea name="code" class="JScript" cols="60" rows="1">
140var node = Y.get('#demo');
141
142var anim = new Y.Anim({
143    node: node,
144    from: {
145        backgroundColor:node.getStyle('backgroundColor'),
146        color: node.getStyle('color'),
147        borderColor: node.getStyle('borderTopColor')
148    },
149
150    to: {
151        color: '#fff',
152        backgroundColor:'#ffa928',
153        borderColor: '#71241a'
154    },
155
156    duration: 0.5,
157    iterations: 'infinite',
158    direction: 'alternate'
159});
160</textarea>
161
162<h3>Changing Attributes</h3>
163<p>We don't want the animation running when the link is not hovered over, so we will change the animation attributes depending on whether or not we are over the link.</p>
164<p>We can use a single handler for both mouse the mouseOver and mouseOut events, and set the <code>reverse</code> attribute depending on which event fired.</p>
165<textarea name="code" class="JScript" cols="60" rows="1">
166var hover = function(e) {
167    var reverse = false,
168        iterations = 'infinite';
169
170    if (anim.get('running')) {
171        anim.pause();
172    }
173    if (e.type === 'mouseout') {
174        reverse = true;
175        iterations = 1;
176    }
177    anim.setAtts({
178        'reverse': reverse,
179        'iterations': iterations
180    });
181
182    anim.run();
183};
184</textarea>
185<h3>Running the Animation</h3>
186<p>Finally we add event handlers to run the animation.</p>
187<textarea name="code" class="JScript" cols="60" rows="1">
188node.on('mouseover', hover);
189node.on('mouseout', hover);
190</textarea>
191
192<h3>Full Script Source</h3>
193<textarea name="code" class="JScript" cols="60" rows="1">
194YUI().use('anim-color', function(Y) {
195    var node = Y.get('#demo');
196
197    var anim = new Y.Anim({
198        node: node,
199        from: {
200            backgroundColor:node.getStyle('backgroundColor'),
201            color: node.getStyle('color'),
202            borderColor: node.getStyle('borderTopColor')
203        },
204
205        to: {
206            color: '#fff',
207            backgroundColor:'#ffa928',
208            borderColor: '#71241a'
209        },
210
211        duration: 0.5,
212        iterations: 'infinite',
213        direction: 'alternate'
214    });
215
216    var hover = function(e) {
217        var reverse = false,
218            iterations = 'infinite';
219
220        if (anim.get('running')) {
221            anim.pause();
222        }
223        if (e.type === 'mouseout') {
224            reverse = true;
225            iterations = 1;
226        }
227        anim.setAtts({
228            'reverse': reverse,
229            'iterations': iterations
230        });
231
232        anim.run();
233    };
234
235    node.on('mouseover', hover);
236    node.on('mouseout', hover);
237});
238
239</textarea>
240
241                                </div>
242                                <div class="yui-u sidebar">
243                                       
244                               
245                                        <div id="examples" class="mod box4">
246                        <div class="hd">
247                                                <h4>
248    Animation Utility Examples:</h4>
249                        </div>
250                                                <div class="bd">
251                                                        <ul>
252                                                                <li><a href='../anim/basic.html'>Basic Animation</a></li><li><a href='../anim/easing.html'>Animation Easing</a></li><li><a href='../anim/colors.html'>Animating Colors</a></li><li class='selected'><a href='../anim/alt-iterations.html'>Alternating Iterations</a></li><li><a href='../anim/anim-xy.html'>Animating XY Position</a></li><li><a href='../anim/curve.html'>Animating Along a Curved Path</a></li><li><a href='../anim/scroll.html'>Animated Scrolling</a></li><li><a href='../anim/reverse.html'>Reversing an Animation</a></li><li><a href='../anim/end-event.html'>Using the End Event</a></li><li><a href='../anim/anim-chaining.html'>Chaining Animations Using the <code>end</code> Event</a></li>                                                 </ul>
253                                                </div>
254                                        </div>
255                                       
256                                        <div class="mod box4">
257                        <div class="hd">
258                                                <h4>More Animation Utility Resources:</h4>
259                        </div>
260                        <div class="bd">
261                                                <ul>
262                                                        <!-- <li><a href="http://developer.yahoo.com/yui/anim/">User's Guide</a> (external)</li> -->
263                                                <li><a href="../../api/module_anim.html">API Documentation</a></li>
264</ul>
265                        </div>
266                                        </div>
267                          </div>
268                </div>
269               
270                </div>
271        </div>
272
273
274<div class="yui-b toc3" id="tocWrapper">
275<!-- TABLE OF CONTENTS -->
276<div id="toc">
277       
278<ul>
279<li class="sect first">YUI 3.x Project</li><li class="item"><a title="The Yahoo! User Interface (YUI) Library, 3.x Branch, " href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site (external)</a></li><li class="item"><a title="Examples of every YUI utility and control in action" href="../../examples/">YUI 3 Examples</a></li><li class="item"><a title="Instantly searchable API documentation for the entire YUI library." href="../../api/">YUI 3 API Docs</a></li><li class="item"><a title="The YUI Library can be downloaded from SourceForge" href="http://sourceforge.net/projects/yui/">YUI 3 on Sourceforge (external)</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/3/license.html">YUI License (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="item"><a title="YUI (Global Prerequisite) - Functional Examples" href="../../examples/yui/index.html">YUI (Global Prerequisite)</a></li><li class="item"><a title="Event - Functional Examples" href="../../examples/event/index.html">Event</a></li><li class="item"><a title="Node - Functional Examples" href="../../examples/node/index.html">Node</a></li><li class="sect">YUI 3 Component Infrastructure - Examples</li><li class="item"><a title="Attribute - Functional Examples" href="../../examples/attribute/index.html">Attribute</a></li><li class="item"><a title="Base - Functional Examples" href="../../examples/base/index.html">Base</a></li><li class="sect">YUI 3 Utilities - Examples</li><li class="item"><a title="Animation - Functional Examples" href="../../examples/anim/index.html">Animation</a></li><li class="item"><a title="Cookie - Functional Examples" href="../../examples/cookie/index.html">Cookie</a></li><li class="item"><a title="Drag &amp; Drop - Functional Examples" href="../../examples/dd/index.html">Drag &amp; Drop</a></li><li class="item"><a title="Get - Functional Examples" href="../../examples/get/index.html">Get</a></li><li class="item"><a title="IO - Functional Examples" href="../../examples/io/index.html">IO</a></li><li class="item"><a title="JSON (JavaScript Object Notation) - Functional Examples" href="../../examples/json/index.html">JSON</a></li><li class="item"><a title="Queue - Functional Examples" href="../../examples/queue/index.html">Queue</a></li><li class="sect">YUI 3 CSS - Examples</li><li class="item"><a title="YUI CSS Reset - Functional Examples" href="../../examples/cssreset/index.html">CSS Reset</a></li><li class="item"><a title="YUI Fonts - Functional Examples" href="../../examples/cssfonts/index.html">CSS Fonts</a></li><li class="item"><a title="YUI Grids - Functional Examples" href="../../examples/cssgrids/index.html">CSS Grids</a></li><li class="item"><a title="YUI Base - Functional Examples" href="../../examples/cssbase/index.html">CSS Base</a></li><li class="sect">The YUI Community</li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="item"><a title="The Yahoo! Group YDN-JavaScript hosts the YUI community forum" href="http://tech.groups.yahoo.com/group/ydn-javascript/">YUI Forum (external)</a></li><li class="item"><a title="The Yahoo! Group yui3 is dedicated to the 3.x branch of the Yahoo! User Interface (YUI) Library." href="http://tech.groups.yahoo.com/group/yui3/">YUI 3 Forum (external)</a></li><li class="item"><a title="YUI is used by Yahoo! and by hundreds of other sites, including many you know and love." href="/yui/poweredby/">YUI Sightings (external)</a></li><li class="item"><a title="Videos and podcasts from the YUI Team and from the Yahoo! frontend engineering community." href="http://developer.yahoo.com/yui/theater/">YUI Theater (external)</a></li><li class="sect">YUI Articles on the YUI Website</li><li class="item"><a title="Answers to Frequently Asked Questions about the YUI Library" href="http://developer.yahoo.com/yui/articles/faq/">YUI FAQ (external)</a></li><li class="item"><a title="Yahoo!'s philosophy of Graded Browser Support" href="http://developer.yahoo.com/yui/articles/gbs/">Graded Browser Support (external)</a></li><li class="item"><a title="Reporting Bugs and Making Feature Requests for YUI Components" href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests (external)</a></li><li class="item"><a title="Serve YUI source files from Yahoo! -- free, fast, and simple" href="http://developer.yahoo.com/yui/3/articles/hosting/">Serving YUI Files from Yahoo! (external)</a></li></ul>
280</div>
281</div>
282        </div><!--closes bd-->
283
284        <div id="ft">
285        <p class="first">Copyright &copy; 2008 Yahoo! Inc. All rights reserved.</p>
286        <p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> -
287            <a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> -
288            <a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> -
289            <a href="http://careers.yahoo.com/">Job Openings</a></p>
290        </div>
291</div>
292<script src="../../assets/dpSyntaxHighlighter.js"></script>
293<script language="javascript"> 
294dp.SyntaxHighlighter.HighlightAll('code'); 
295</script>
296</body>
297</html>
298<!-- delightfuture.corp.yahoo.com uncompressed/chunked Wed Aug 13 16:45:29 PDT 2008 -->
Note: See TracBrowser for help on using the repository browser.