NodeList-fx.html
5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Testing dojo.fx extensions to dojo.NodeList</title>
<style type="text/css">
@import "../resources/dojo.css";
</style>
<script type="text/javascript" src="../dojo.js" data-dojo-config="isDebug: true, popup: true"></script>
<script type="text/javascript">
require(["doh", "dojo/aspect", "dojo/dom-style", "dojo/query", "dojo/NodeList-fx", "dojo/domReady!"],
function(doh, aspect, domStyle, query){
doh.register("NodeList-fx",
[
function fadeOut(){
query("p").style("opacity", 1);
var anim = query("p").fadeOut();
var d = new doh.Deferred();
aspect.after(anim, "onEnd", d.getTestCallback(function(){
query("p").forEach(function(item){
doh.is(0, domStyle.get(item, "opacity"), "opacity for " + item);
});
}), true);
anim.play();
return d;
},
function fadeIn(){
query("p").style("opacity", 0);
var anim = query("p").fadeIn();
var d = new doh.Deferred();
aspect.after(anim, "onEnd", d.getTestCallback(function(){
query("p").forEach(function(item){
doh.is(1, domStyle.get(item, "opacity"), "opacity for " + item);
});
}), true);
anim.play();
return d;
},
function wipeOut(){
query("p").style("height", "");
var anim = query("p").wipeOut();
var d = new doh.Deferred();
aspect.after(anim, "onEnd", d.getTestCallback(function(){
query("p").forEach(function(item){
doh.is(0, domStyle.get(item, "height"), "height for " + item);
});
}), true);
anim.play();
return d;
},
function wipeIn(){
query("p").style("height", 0);
var anim = query("p").wipeIn();
var d = new doh.Deferred();
aspect.after(anim, "onEnd", d.getTestCallback(function(){
query("p").forEach(function(item){
// FIXME: need a more robust test for "have wiped all the way in"
doh.isNot(0, domStyle.get(item, "height"), "height for " + item);
});
}), true);
anim.play();
return d;
},
function slideTo(){
var anim = query("p").slideTo({
left: 500
});
var d = new doh.Deferred();
aspect.after(anim, "onEnd", d.getTestCallback(function(){
query("p").forEach(function(item){
// FIXME: need a more robust test for "have wiped all the way in"
doh.is(500, domStyle.get(item, "left"), "left for " + item);
});
}), true);
anim.play();
return d;
},
function anim(){
query("p").style("position", "");
query("p").style("left", "");
var anim = query("p").anim({
width: 500
});
console.debug(anim);
var d = new doh.Deferred();
aspect.after(anim, "onEnd", d.getTestCallback(function(){
/*
query("p").forEach(function(item){
// FIXME: need a more robust test for "have wiped all the way in"
doh.is(500, domStyle.get(item, "width"), "width for" + item);
}));
*/
}), true);
return d;
},
function auto(){
var d = new doh.Deferred(), x = 0;
var nl = query("p")
.fadeOut({
auto:true,
onEnd:function(){
if(!x){
// onend fires foreach in the list. only dfd once.
x++; d.callback(true);
}
}
})
// past here we're expecting a NodeList back, not an Animation
.at(0)
.forEach(d.getTestErrback(function(n){
// TODO: this test is meaningless
doh.t(true); // it worked.
}))
;
doh.t(nl.length, "query() found some nodes"); // ensure we actually will do _something_
return d;
}
]
);
doh.run();
});
</script>
</head>
<body>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper
sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta
rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.
Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis.
Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitae
risus.
</p>
<p>
Aliquam vitae enim. Duis scelerisque metus auctor est venenatis
imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer lorem
nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in
massa bibendum suscipit. Integer eros. Nullam suscipit mauris. In
pellentesque. Mauris ipsum est, pharetra semper, pharetra in, viverra
quis, tellus. Etiam purus. Quisque egestas, tortor ac cursus lacinia,
felis leo adipiscing nisi, et rhoncus elit dolor eget eros. Fusce ut
quam. Suspendisse eleifend leo vitae ligula. Nulla facilisi. Nulla
rutrum, erat vitae lacinia dictum, pede purus imperdiet lacus, ut
semper velit ante id metus. Praesent massa dolor, porttitor sed,
pulvinar in, consequat ut, leo. Nullam nec est. Aenean id risus blandit
tortor pharetra congue. Suspendisse pulvinar.
</p>
<p>
Aliquam vitae enim. Duis scelerisque metus auctor est venenatis
imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer lorem
nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in
massa bibendum suscipit. Integer eros. Nullam suscipit mauris. In
pellentesque. Mauris ipsum est, pharetra semper, pharetra in, viverra
quis, tellus. Etiam purus. Quisque egestas, tortor ac cursus lacinia,
felis leo adipiscing nisi, et rhoncus elit dolor eget eros. Fusce ut
quam. Suspendisse eleifend leo vitae ligula. Nulla facilisi. Nulla
rutrum, erat vitae lacinia dictum, pede purus imperdiet lacus, ut
semper velit ante id metus. Praesent massa dolor, porttitor sed,
pulvinar in, consequat ut, leo. Nullam nec est. Aenean id risus blandit
tortor pharetra congue. Suspendisse pulvinar.
</p>
</body>
</html>