|
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>Alternating Iterations</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>Alternating Iterations</h1> |
|
|
34 |
|
|
|
35 |
<div class="exampleIntro"> |
|
|
36 |
<p>This demonstrates how to use the <code>iterations</code> attribute to run multiple iterations of the animation.</p> |
|
|
37 |
<p>Mouse over the link to begin the animation.</p> |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
</div> |
|
|
41 |
|
|
|
42 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
<a href="#" id="demo">hover me</a> |
|
|
46 |
<script type="text/javascript"> |
|
|
47 |
YUI({base:"../../build/", timeout: 10000}).use("anim", function(Y) { |
|
|
48 |
var node = Y.get('#demo'); |
|
|
49 |
|
|
|
50 |
var anim = new Y.Anim({ |
|
|
51 |
node: node, |
|
|
52 |
from: { |
|
|
53 |
backgroundColor:node.getStyle('backgroundColor'), |
|
|
54 |
color: node.getStyle('color'), |
|
|
55 |
borderColor: node.getStyle('borderTopColor') |
|
|
56 |
}, |
|
|
57 |
|
|
|
58 |
to: { |
|
|
59 |
color: '#fff', |
|
|
60 |
backgroundColor:'#ffa928', |
|
|
61 |
borderColor: '#71241a' |
|
|
62 |
}, |
|
|
63 |
|
|
|
64 |
duration: 0.5, |
|
|
65 |
iterations: 'infinite', |
|
|
66 |
direction: 'alternate' |
|
|
67 |
}); |
|
|
68 |
|
|
|
69 |
var hover = function(e) { |
|
|
70 |
var reverse = false, |
|
|
71 |
iterations = 'infinite'; |
|
|
72 |
|
|
|
73 |
if (anim.get('running')) { |
|
|
74 |
anim.pause(); |
|
|
75 |
} |
|
|
76 |
if (e.type === 'mouseout') { |
|
|
77 |
reverse = true; |
|
|
78 |
iterations = 1; |
|
|
79 |
} |
|
|
80 |
anim.setAttrs({ |
|
|
81 |
'reverse': reverse, |
|
|
82 |
'iterations': iterations |
|
|
83 |
}); |
|
|
84 |
|
|
|
85 |
anim.run(); |
|
|
86 |
}; |
|
|
87 |
|
|
|
88 |
node.on('mouseover', hover); |
|
|
89 |
node.on('mouseout', hover); |
|
|
90 |
}); |
|
|
91 |
|
|
|
92 |
</script> |
|
|
93 |
|
|
|
94 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
95 |
|
|
|
96 |
</body> |
|
|
97 |
</html> |