| 2150 |
mathias |
1 |
<html>
|
|
|
2 |
<head>
|
|
|
3 |
<title>testing Core FX</title>
|
|
|
4 |
<style type="text/css">
|
|
|
5 |
@import "../../resources/dojo.css";
|
|
|
6 |
</style>
|
|
|
7 |
<script type="text/javascript"
|
|
|
8 |
src="../../dojo.js"
|
|
|
9 |
djConfig="isDebug: true"></script>
|
|
|
10 |
<script type="text/javascript" src="../../_base/fx.js"></script>
|
|
|
11 |
<script type="text/javascript">
|
|
|
12 |
var duration = 1000;
|
|
|
13 |
dojo.require("doh.runner");
|
|
|
14 |
dojo.addOnLoad(function(){
|
|
|
15 |
doh.register("t",
|
|
|
16 |
[
|
|
|
17 |
{
|
|
|
18 |
name: "fadeOut",
|
|
|
19 |
timeout: 1500,
|
|
|
20 |
runTest: function(t){
|
|
|
21 |
var opacity = dojo.style('foo', 'opacity');
|
|
|
22 |
t.is(1, opacity);
|
|
|
23 |
var anim = dojo.fadeOut({ node: 'foo', duration: duration });
|
|
|
24 |
var d = new doh.Deferred();
|
|
|
25 |
dojo.connect(anim, "onEnd", null, function(){
|
|
|
26 |
var opacity = dojo.style('foo', 'opacity');
|
|
|
27 |
// console.debug(anim._start);
|
|
|
28 |
var elapsed = (new Date()) - anim._start;
|
|
|
29 |
t.is(0, opacity);
|
|
|
30 |
t.assertTrue(elapsed >= duration);
|
|
|
31 |
d.callback(true);
|
|
|
32 |
});
|
|
|
33 |
anim._start = new Date();
|
|
|
34 |
anim.play();
|
|
|
35 |
return d;
|
|
|
36 |
}
|
|
|
37 |
},
|
|
|
38 |
{
|
|
|
39 |
name: "fadeIn",
|
|
|
40 |
timeout: 1500,
|
|
|
41 |
runTest: function(t){
|
|
|
42 |
var opacity = dojo.style('foo', 'opacity');
|
|
|
43 |
t.is(0, opacity);
|
|
|
44 |
var anim = dojo.fadeIn({ node: 'foo', duration: duration });
|
|
|
45 |
var d = new doh.Deferred();
|
|
|
46 |
dojo.connect(anim, "onEnd", null, function(){
|
|
|
47 |
var opacity = dojo.style('foo', 'opacity');
|
|
|
48 |
// console.debug(anim._start);
|
|
|
49 |
var elapsed = (new Date()) - anim._start;
|
|
|
50 |
t.is(1, opacity);
|
|
|
51 |
t.assertTrue(elapsed >= duration);
|
|
|
52 |
d.callback(true);
|
|
|
53 |
});
|
|
|
54 |
anim._start = new Date();
|
|
|
55 |
anim.play();
|
|
|
56 |
return d;
|
|
|
57 |
}
|
|
|
58 |
},
|
|
|
59 |
{
|
|
|
60 |
name: "animateColor",
|
|
|
61 |
timeout: 1500,
|
|
|
62 |
runTest: function(t){
|
|
|
63 |
var d = new doh.Deferred();
|
|
|
64 |
var anim = dojo.animateProperty({
|
|
|
65 |
node: "foo",
|
|
|
66 |
duration: duration,
|
|
|
67 |
properties: {
|
|
|
68 |
color: { start: "black", end: "white" },
|
|
|
69 |
backgroundColor: { start: "white", end: "black" }
|
|
|
70 |
}
|
|
|
71 |
});
|
|
|
72 |
dojo.connect(anim, "onEnd", anim, function(){
|
|
|
73 |
d.callback(true);
|
|
|
74 |
});
|
|
|
75 |
anim.play();
|
|
|
76 |
return d;
|
|
|
77 |
}
|
|
|
78 |
},
|
|
|
79 |
{
|
|
|
80 |
name: "animateColorBack",
|
|
|
81 |
timeout: 1500,
|
|
|
82 |
runTest: function(t){
|
|
|
83 |
var d = new doh.Deferred();
|
|
|
84 |
var anim = dojo.animateProperty({
|
|
|
85 |
node: "foo",
|
|
|
86 |
duration: duration,
|
|
|
87 |
properties: {
|
|
|
88 |
color: { end: "black" },
|
|
|
89 |
backgroundColor: { end: "#5d81b4" },
|
|
|
90 |
letterSpacing: { start: 0, end: 10 }
|
|
|
91 |
}
|
|
|
92 |
});
|
|
|
93 |
dojo.connect(anim, "onEnd", anim, function(){
|
|
|
94 |
d.callback(true);
|
|
|
95 |
});
|
|
|
96 |
anim.play();
|
|
|
97 |
return d;
|
|
|
98 |
}
|
|
|
99 |
},
|
|
|
100 |
{
|
|
|
101 |
name: "animateHeight",
|
|
|
102 |
timeout: 1500,
|
|
|
103 |
runTest: function(t){
|
|
|
104 |
var startHeight = dojo.marginBox("foo").h;
|
|
|
105 |
var endHeight = Math.round(startHeight / 2);
|
|
|
106 |
|
|
|
107 |
var anim = dojo.animateProperty({
|
|
|
108 |
node: "foo",
|
|
|
109 |
properties: { height: { end: endHeight } },
|
|
|
110 |
duration: duration
|
|
|
111 |
});
|
|
|
112 |
|
|
|
113 |
var d = new doh.Deferred();
|
|
|
114 |
|
|
|
115 |
dojo.connect(anim, "onEnd", anim, function(){
|
|
|
116 |
var elapsed = (new Date().valueOf()) - anim._startTime;
|
|
|
117 |
t.assertTrue(elapsed >= duration);
|
|
|
118 |
var height = dojo.marginBox("foo").h;
|
|
|
119 |
t.is(height, endHeight);
|
|
|
120 |
d.callback(true);
|
|
|
121 |
});
|
|
|
122 |
|
|
|
123 |
anim.play();
|
|
|
124 |
return d;
|
|
|
125 |
}
|
|
|
126 |
}
|
|
|
127 |
]
|
|
|
128 |
);
|
|
|
129 |
doh.run();
|
|
|
130 |
});
|
|
|
131 |
</script>
|
|
|
132 |
<style type="text/css">
|
|
|
133 |
body {
|
|
|
134 |
margin: 1em;
|
|
|
135 |
background-color: #DEDEDE;
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
.box {
|
|
|
139 |
color: #292929;
|
|
|
140 |
/* color: #424242; */
|
|
|
141 |
/* text-align: left; */
|
|
|
142 |
width: 300px;
|
|
|
143 |
border: 1px solid #BABABA;
|
|
|
144 |
background-color: white;
|
|
|
145 |
padding-left: 10px;
|
|
|
146 |
padding-right: 10px;
|
|
|
147 |
margin-left: 10px;
|
|
|
148 |
-o-border-radius: 10px;
|
|
|
149 |
-moz-border-radius: 12px;
|
|
|
150 |
-webkit-border-radius: 10px;
|
|
|
151 |
/* -opera-border-radius: 10px; */
|
|
|
152 |
border-radius: 10px;
|
|
|
153 |
-moz-box-sizing: border-box;
|
|
|
154 |
-opera-sizing: border-box;
|
|
|
155 |
-webkit-box-sizing: border-box;
|
|
|
156 |
-khtml-box-sizing: border-box;
|
|
|
157 |
box-sizing: border-box;
|
|
|
158 |
overflow: hidden;
|
|
|
159 |
/* position: absolute; */
|
|
|
160 |
}
|
|
|
161 |
</style>
|
|
|
162 |
</head>
|
|
|
163 |
<body>
|
|
|
164 |
<h1>testing Core FX</h1>
|
|
|
165 |
<form name="testForm">
|
|
|
166 |
<input type="button" onClick="dojo.fadeOut({ node: 'foo', duration: 1000 }).play()" value="fade out"></input>
|
|
|
167 |
<input type="button" onClick="dojo.fadeIn({ node: 'foo', duration: 1000 }).play()" value="fade in"></input>
|
|
|
168 |
</form>
|
|
|
169 |
<div id="foo" class="box" style="float: left;">
|
|
|
170 |
<p>
|
|
|
171 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
|
|
|
172 |
semper sagittis velit. Cras in mi. Duis porta mauris ut ligula.
|
|
|
173 |
Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla
|
|
|
174 |
facilisi. Maecenas luctus venenatis nulla. In sit amet dui non mi
|
|
|
175 |
semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum
|
|
|
176 |
magna. Sed vitae risus.
|
|
|
177 |
</p>
|
|
|
178 |
<p>
|
|
|
179 |
Aliquam vitae enim. Duis scelerisque metus auctor est venenatis
|
|
|
180 |
imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer
|
|
|
181 |
lorem nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean
|
|
|
182 |
id mi in massa bibendum suscipit. Integer eros. Nullam suscipit
|
|
|
183 |
mauris. In pellentesque. Mauris ipsum est, pharetra semper,
|
|
|
184 |
pharetra in, viverra quis, tellus. Etiam purus. Quisque egestas,
|
|
|
185 |
tortor ac cursus lacinia, felis leo adipiscing nisi, et rhoncus
|
|
|
186 |
elit dolor eget eros. Fusce ut quam. Suspendisse eleifend leo vitae
|
|
|
187 |
ligula. Nulla facilisi. Nulla rutrum, erat vitae lacinia dictum,
|
|
|
188 |
pede purus imperdiet lacus, ut semper velit ante id metus. Praesent
|
|
|
189 |
massa dolor, porttitor sed, pulvinar in, consequat ut, leo. Nullam
|
|
|
190 |
nec est. Aenean id risus blandit tortor pharetra congue.
|
|
|
191 |
Suspendisse pulvinar.
|
|
|
192 |
</p>
|
|
|
193 |
</div>
|
|
|
194 |
</body>
|
|
|
195 |
</html>
|
|
|
196 |
|