Debian Codegraph @

closure-library/closure/goog/demos/cssspriteanimation.html

raw
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright 2010 The Closure Library Authors. All Rights Reserved.
5
6 Use of this source code is governed by the Apache License, Version 2.0.
7 See the COPYING file for details.
8 -->
9 <head>
10 <title>CssSpriteAnimation demo</title>
11 <script type="text/javascript" src="../base.js"></script>
12 <script type="text/javascript">
13 goog.require('goog.events');
14 goog.require('goog.fx.Animation');
15 goog.require('goog.fx.CssSpriteAnimation');
16 goog.require('goog.math.Box');
17 goog.require('goog.math.Size');
18 </script>
19 <style>
20
21 .icon {
22 width: 11px;
23 height: 11px;
24 background-image: url(../images/offlineicons.png);
25 }
26
27 #test1,
28 #test3 {
29 background-position: 0 -11px;
30 }
31
32 #test2 {
33 background-position: 0 -132px;
34 }
35 </style>
36 </head>
37 <body>
38
39 <p>The following just runs and runs...</p>
40 <div class=icon id=test1></div>
41
42 <p>The animation is just an ordinary animation so you can pause it etc.
43 <div class=icon id=test2></div>
44
45 <p>
46 <button onclick="sa2.play()">Play</button>
47 <button onclick="sa2.pause()">Pause</button>
48 </p>
49
50 <p>The animation can be played once by stopping it after it finishes for the
51 first time.
52
53 <div class=icon id=test3></div>
54
55 <script>
56
57 var size = new goog.math.Size(11, 11);
58
59 var el = document.getElementById('test1');
60 var sa = new goog.fx.CssSpriteAnimation(el, size,
61 new goog.math.Box(11, 11, 99, 0), 1200);
62 sa.play();
63
64 var el2 = document.getElementById('test2');
65 var sa2 = new goog.fx.CssSpriteAnimation(el2, size,
66 new goog.math.Box(132, 11, 132 + 11 * 8, 0), 1200);
67 sa2.play();
68
69 var el3 = document.getElementById('test3');
70 var sa3 = new goog.fx.CssSpriteAnimation(el3, size,
71 new goog.math.Box(11, 11, 99, 0), 8000);
72 goog.events.listen(sa3, goog.fx.Transition.EventType.FINISH, function() {
73 sa3.stop();
74 });
75 sa3.play();
76
77 </script>
78
79 </body>
80 </html>