-
Notifications
You must be signed in to change notification settings - Fork 0
/
NodeList-fx.js
221 lines (208 loc) · 7.57 KB
/
NodeList-fx.js
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
define(["./query", "./_base/lang", "./aspect", "./_base/fx", "./fx"],
function(query, lang, aspect, baseFx, coreFx){
// module:
// dojo/NodeList-fx
/*=====
return function(){
// summary:
// Adds dojo.fx animation support to dojo.query() by extending the NodeList class
// with additional FX functions. NodeList is the array-like object used to hold query results.
};
=====*/
var NodeList = query.NodeList;
lang.extend(NodeList, {
_anim: function(obj, method, args){
args = args||{};
var a = coreFx.combine(
this.map(function(item){
var tmpArgs = { node: item };
lang.mixin(tmpArgs, args);
return obj[method](tmpArgs);
})
);
return args.auto ? a.play() && this : a; // dojo/_base/fx.Animation|dojo/NodeList
},
wipeIn: function(args){
// summary:
// wipe in all elements of this NodeList via `dojo/fx.wipeIn()`
//
// args: Object?
// Additional dojo/_base/fx.Animation arguments to mix into this set with the addition of
// an `auto` parameter.
//
// returns: dojo/_base/fx.Animation|dojo/NodeList
// A special args member `auto` can be passed to automatically play the animation.
// If args.auto is present, the original dojo/NodeList will be returned for further
// chaining. Otherwise the dojo/_base/fx.Animation instance is returned and must be .play()'ed
//
// example:
// Fade in all tables with class "blah":
// | dojo.query("table.blah").wipeIn().play();
//
// example:
// Utilizing `auto` to get the NodeList back:
// | dojo.query(".titles").wipeIn({ auto:true }).onclick(someFunction);
//
return this._anim(coreFx, "wipeIn", args); // dojo/_base/fx.Animation|dojo/NodeList
},
wipeOut: function(args){
// summary:
// wipe out all elements of this NodeList via `dojo/fx.wipeOut()`
//
// args: Object?
// Additional dojo/_base/fx.Animation arguments to mix into this set with the addition of
// an `auto` parameter.
//
// returns: dojo/_base/fx.Animation|dojo/NodeList
// A special args member `auto` can be passed to automatically play the animation.
// If args.auto is present, the original dojo/NodeList will be returned for further
// chaining. Otherwise the dojo/_base/fx.Animation instance is returned and must be .play()'ed
//
// example:
// Wipe out all tables with class "blah":
// | dojo.query("table.blah").wipeOut().play();
return this._anim(coreFx, "wipeOut", args); // dojo/_base/fx.Animation|dojo/NodeList
},
slideTo: function(args){
// summary:
// slide all elements of the node list to the specified place via `dojo/fx.slideTo()`
//
// args: Object?
// Additional dojo/_base/fx.Animation arguments to mix into this set with the addition of
// an `auto` parameter.
//
// returns: dojo/_base/fx.Animation|dojo/NodeList
// A special args member `auto` can be passed to automatically play the animation.
// If args.auto is present, the original dojo/NodeList will be returned for further
// chaining. Otherwise the dojo/_base/fx.Animation instance is returned and must be .play()'ed
//
// example:
// | Move all tables with class "blah" to 300/300:
// | dojo.query("table.blah").slideTo({
// | left: 40,
// | top: 50
// | }).play();
return this._anim(coreFx, "slideTo", args); // dojo/_base/fx.Animation|dojo/NodeList
},
fadeIn: function(args){
// summary:
// fade in all elements of this NodeList via `dojo.fadeIn`
//
// args: Object?
// Additional dojo/_base/fx.Animation arguments to mix into this set with the addition of
// an `auto` parameter.
//
// returns: dojo/_base/fx.Animation|dojo/NodeList
// A special args member `auto` can be passed to automatically play the animation.
// If args.auto is present, the original dojo/NodeList will be returned for further
// chaining. Otherwise the dojo/_base/fx.Animation instance is returned and must be .play()'ed
//
// example:
// Fade in all tables with class "blah":
// | dojo.query("table.blah").fadeIn().play();
return this._anim(baseFx, "fadeIn", args); // dojo/_base/fx.Animation|dojo/NodeList
},
fadeOut: function(args){
// summary:
// fade out all elements of this NodeList via `dojo.fadeOut`
//
// args: Object?
// Additional dojo/_base/fx.Animation arguments to mix into this set with the addition of
// an `auto` parameter.
//
// returns: dojo/_base/fx.Animation|dojo/NodeList
// A special args member `auto` can be passed to automatically play the animation.
// If args.auto is present, the original dojo/NodeList will be returned for further
// chaining. Otherwise the dojo/_base/fx.Animation instance is returned and must be .play()'ed
//
// example:
// Fade out all elements with class "zork":
// | dojo.query(".zork").fadeOut().play();
// example:
// Fade them on a delay and do something at the end:
// | var fo = dojo.query(".zork").fadeOut();
// | aspect.after(fo, "onEnd", function(){ /*...*/ }, true);
// | fo.play();
// example:
// Using `auto`:
// | dojo.query("li").fadeOut({ auto:true }).filter(filterFn).forEach(doit);
//
return this._anim(baseFx, "fadeOut", args); // dojo/_base/fx.Animation|dojo/NodeList
},
animateProperty: function(args){
// summary:
// Animate all elements of this NodeList across the properties specified.
// syntax identical to `dojo.animateProperty`
//
// args: Object?
// Additional dojo/_base/fx.Animation arguments to mix into this set with the addition of
// an `auto` parameter.
//
// returns: dojo/_base/fx.Animation|dojo/NodeList
// A special args member `auto` can be passed to automatically play the animation.
// If args.auto is present, the original dojo/NodeList will be returned for further
// chaining. Otherwise the dojo/_base/fx.Animation instance is returned and must be .play()'ed
//
// example:
// | dojo.query(".zork").animateProperty({
// | duration: 500,
// | properties: {
// | color: { start: "black", end: "white" },
// | left: { end: 300 }
// | }
// | }).play();
//
// example:
// | dojo.query(".grue").animateProperty({
// | auto:true,
// | properties: {
// | height:240
// | }
// | }).onclick(handler);
return this._anim(baseFx, "animateProperty", args); // dojo/_base/fx.Animation|dojo/NodeList
},
anim: function( /*Object*/ properties,
/*Integer?*/ duration,
/*Function?*/ easing,
/*Function?*/ onEnd,
/*Integer?*/ delay){
// summary:
// Animate one or more CSS properties for all nodes in this list.
// The returned animation object will already be playing when it
// is returned. See the docs for `dojo.anim` for full details.
// properties: Object
// the properties to animate. does NOT support the `auto` parameter like other
// NodeList-fx methods.
// duration: Integer?
// Optional. The time to run the animations for
// easing: Function?
// Optional. The easing function to use.
// onEnd: Function?
// A function to be called when the animation ends
// delay:
// how long to delay playing the returned animation
// example:
// Another way to fade out:
// | dojo.query(".thinger").anim({ opacity: 0 });
// example:
// animate all elements with the "thigner" class to a width of 500
// pixels over half a second
// | dojo.query(".thinger").anim({ width: 500 }, 700);
var canim = coreFx.combine(
this.map(function(item){
return baseFx.animateProperty({
node: item,
properties: properties,
duration: duration||350,
easing: easing
});
})
);
if(onEnd){
aspect.after(canim, "onEnd", onEnd, true);
}
return canim.play(delay||0); // dojo/_base/fx.Animation
}
});
return NodeList;
});