source: Dev/branches/rest-dojo-ui/client/dojox/fx/split.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 22.0 KB
Line 
1define(["dojo/_base/lang", "dojo/dom", "dojo/_base/window", "dojo/_base/html", "dojo/dom-geometry",
2                "dojo/dom-construct", "dojo/dom-attr", "dojo/_base/fx", "dojo/fx", "./_base", "dojo/fx/easing", "dojo/_base/connect"],
3        function(lang, dom, winUtil, htmlUtil, domGeom, domConstruct, domAttr, baseFx, coreFx, fxExt, easingUtil, connectUtil){
4var dojoxFx = lang.getObject("dojox.fx");
5lang.mixin(dojoxFx,{
6        _split: function(/*Object*/ args){
7                // summary: Split a node into rectangular pieces and animate them.
8                //
9                // description:
10                //              Returns an animation that will split the node into a grid
11                //              of pieces that move independently.
12                //
13                //      args:
14                //              args.crop: Boolean - If true, pieces will only be visible inside node's boundries
15                //              args.rows: Integer - The number of horizontal pieces (default is 3)
16                //              args.columns: Integer - The number of vertical pieces (default is 3)
17                //              args.pieceAnimation: Function(piece, x, y, coords) - Returns either the dojo.Animation
18                //              or an array of dojo.Animation objects for the piece at location (x, y) in the node's grid;
19                //              coords is the result of dojo.coords(args.node, true);
20
21                args.rows = args.rows || 3;
22                args.columns = args.columns || 3;
23                args.duration = args.duration || 1000;
24
25                var node = args.node = dom.byId(args.node),
26                        parentNode = node.parentNode,
27                        pNode = parentNode,
28                        body = winUtil.body(),
29                        _pos = "position"
30                ;
31
32                while(pNode && pNode != body && htmlUtil.style(pNode, _pos) == "static"){
33                        pNode = pNode.parentNode;
34                }
35
36                var pCoords = pNode != body ? domGeom.position(pNode, true) : { x: 0, y: 0 },
37                        coords = domGeom.position(node, true),
38                        nodeHeight = htmlUtil.style(node, "height"),
39                        nodeWidth = htmlUtil.style(node, "width"),
40                        hBorder = htmlUtil.style(node, "borderLeftWidth") + htmlUtil.style(node, "borderRightWidth"),
41                        vBorder = htmlUtil.style(node, "borderTopWidth") + htmlUtil.style(node, "borderBottomWidth"),
42                        pieceHeight = Math.ceil(nodeHeight / args.rows),
43                        pieceWidth = Math.ceil(nodeWidth / args.columns),
44                        container = domConstruct.create(node.tagName, {
45                                style: {
46                                        position: "absolute",
47                                        padding: 0,
48                                        margin: 0,
49                                        border:"none",
50                                        top: coords.y - pCoords.y + "px",
51                                        left: coords.x - pCoords.x + "px",
52                                        height: nodeHeight + vBorder + "px",
53                                        width: nodeWidth + hBorder + "px",
54                                        background: "none",
55                                        overflow: args.crop ? "hidden" : "visible",
56                                        zIndex: htmlUtil.style(node, "zIndex")
57                                }
58                        }, node, "after"),
59                        animations = [],
60                        pieceHelper = domConstruct.create(node.tagName, {
61                                style: {
62                                        position: "absolute",
63                                        border: "none",
64                                        padding: 0,
65                                        margin: 0,
66                                        height: pieceHeight + hBorder + "px",
67                                        width: pieceWidth + vBorder + "px",
68                                        overflow: "hidden"
69                                }
70                        });
71
72                // Create the pieces and their animations
73                for(var y = 0, ly = args.rows; y < ly; y++){
74                        for(var x = 0, lx = args.columns; x < lx; x++){
75                                // Create the piece
76                                var piece = lang.clone(pieceHelper),
77                                        pieceContents = lang.clone(node),
78                                        pTop = y * pieceHeight,
79                                        pLeft = x * pieceWidth
80                                ;
81
82                                // IE hack
83                                pieceContents.style.filter = "";
84
85                                // removing the id attribute from the cloned nodes
86                                domAttr.remove(pieceContents, "id");
87
88                                htmlUtil.style(piece, {
89                                        border: "none",
90                                        overflow: "hidden",
91                                        top: pTop + "px",
92                                        left: pLeft + "px"
93                                });
94                                htmlUtil.style(pieceContents, {
95                                        position: "static",
96                                        opacity: "1",
97                                        marginTop: -pTop + "px",
98                                        marginLeft: -pLeft + "px"
99                                });
100                                piece.appendChild(pieceContents);
101                                container.appendChild(piece);
102
103                                var pieceAnimation = args.pieceAnimation(piece, x, y, coords);
104                                if(lang.isArray(pieceAnimation)){
105                                        // if pieceAnimation is an array, append its elements
106                                        animations = animations.concat(pieceAnimation);
107                                }else{
108                                        // otherwise, append it
109                                        animations.push(pieceAnimation);
110                                }
111                        }
112                }
113                var anim = coreFx.combine(animations);
114                connectUtil.connect(anim, "onEnd", anim, function(){
115                        container.parentNode.removeChild(container);
116                });
117                if(args.onPlay){
118                        connectUtil.connect(anim, "onPlay", anim, args.onPlay);
119                }
120                if(args.onEnd){
121                        connectUtil.connect(anim, "onEnd", anim, args.onEnd);
122                }
123                return anim; // dojo.Animation
124        },
125
126        explode: function(/*Object*/ args){
127                // summary: Explode a node into rectangular pieces
128                //
129                // description:
130                //              Returns an animation that will split the node into a grid
131                //              of pieces that fly away from the center.
132                //
133                //      args:
134                //              args.rows: Integer - The number of horizontal pieces (default is 3)
135                //              args.columns: Integer - The number of vertical pieces (default is 3)
136                //              args.random: Float - If set, pieces fly to random distances, for random durations,
137                //                                                         and in slightly random directions.  The value defines how much
138                //                                                         randomness is introduced.
139                //              args.distance: Float - Multiplier for the distance the pieces fly (even when random)
140                //              args.fade: Boolean - If true, pieces fade out while in motion (default is true)
141                //              args.fadeEasing: Function - If args.fade is true, the fade animations use this easing function
142                //              args.unhide: Boolean - If true, the animation is reversed
143                //              args.sync: Boolean - If args.unhide is true, all the pieces converge at the same time
144                //                                                       (default is true)
145
146                var node = args.node = dom.byId(args.node);
147                args.rows = args.rows || 3;
148                args.columns = args.columns || 3;
149                args.distance = args.distance || 1;
150                args.duration = args.duration || 1000;
151                args.random = args.random || 0;
152                if(!args.fade){
153                        args.fade = true;
154                }
155                if(typeof args.sync == "undefined"){
156                        args.sync = true;
157                }
158                args.random = Math.abs(args.random);
159
160                // Returns the animation object for each piece
161                args.pieceAnimation = function(piece, x, y, coords){
162                        var pieceHeight = coords.h / args.rows,
163                                pieceWidth = coords.w / args.columns,
164                                distance = args.distance * 2,
165                                duration = args.duration,
166                                ps = piece.style,
167                                startTop = parseInt(ps.top),
168                                startLeft = parseInt(ps.left),
169                                delay = 0,
170                                randomX = 0,
171                                randomY = 0;
172
173                        if(args.random){
174                                var seed = (Math.random() * args.random) + Math.max(1 - args.random, 0);
175                                distance *= seed;
176                                duration *= seed;
177                                // To syncronize, give each piece an appropriate delay so they end together
178                                delay = ((args.unhide && args.sync) || (!args.unhide && !args.sync)) ? (args.duration - duration) : 0;
179                                // Slightly randomize the direction of each piece
180                                randomX = Math.random() - 0.5;
181                                randomY = Math.random() - 0.5;
182                        }
183
184                        var distanceY = ((coords.h - pieceHeight) / 2 - pieceHeight * y),
185                                distanceX = ((coords.w - pieceWidth) / 2 - pieceWidth * x),
186                                distanceXY = Math.sqrt(Math.pow(distanceX, 2) + Math.pow(distanceY, 2)),
187                                endTop = parseInt(startTop - distanceY * distance + distanceXY * randomY),
188                                endLeft = parseInt(startLeft - distanceX * distance + distanceXY * randomX)
189                        ;
190
191                        // Create the animation objects for the piece
192                        // These are separate anim objects so they can have different curves
193                        var pieceSlide = baseFx.animateProperty({
194                                node: piece,
195                                duration: duration,
196                                delay: delay,
197                                easing: (args.easing || (args.unhide ? easingUtil.sinOut : easingUtil.circOut)),
198                                beforeBegin: (args.unhide ? function(){
199                                                if(args.fade){
200                                                        htmlUtil.style(piece, { opacity: "0"});
201                                                }
202                                                ps.top = endTop + "px";
203                                                ps.left = endLeft + "px";
204                                        } : undefined),
205                                properties: {
206                                        top: (args.unhide ? { start: endTop, end: startTop } : { start: startTop, end: endTop }),
207                                        left: (args.unhide ? { start: endLeft, end: startLeft } : { start: startLeft, end: endLeft })
208                                }
209                        });
210                        if(args.fade){
211                                var pieceFade = baseFx.animateProperty({
212                                        node: piece,
213                                        duration: duration,
214                                        delay: delay,
215                                        easing: (args.fadeEasing || easingUtil.quadOut),
216                                        properties: {
217                                                opacity: (args.unhide ? { start: "0", end: "1" } : { start: "1", end: "0" })
218                                        }
219                                });
220
221                                // return both animations as an array
222                                return (args.unhide ? [pieceFade, pieceSlide] : [pieceSlide, pieceFade]);
223                        }else{
224                                // Otherwise return only the slide animation
225                                return pieceSlide;
226                        }
227                };
228
229                var anim = dojoxFx._split(args);
230                if(args.unhide){
231                        connectUtil.connect(anim, "onEnd", null, function(){
232                                htmlUtil.style(node, {opacity: "1" });
233                        });
234                }else{
235                        connectUtil.connect(anim, "onPlay", null, function(){
236                                htmlUtil.style(node, { opacity: "0" });
237                        });
238                }
239                return anim; // dojo.Animation
240        },
241
242        converge: function(/*Object*/ args){
243                args.unhide = true;
244                return dojoxFx.explode(args);
245        },
246
247        disintegrate: function(/*Object*/ args){
248                // summary: Split a node into rectangular pieces and let them fall
249                //
250                // description:
251                //              Returns an animation that will split the node into a grid
252                //              of pieces that drop.
253                //
254                //      args:
255                //              args.rows: Integer - The number of horizontal pieces (default is 5)
256                //              args.columns: Integer - The number of vertical pieces (default is 5)
257                //              args.interval: Float - The number of milliseconds between each piece's animation
258                //              args.distance: Float - The number of the node's heights to drop (default is 1.5)
259                //              args.fade: Boolean - If true, pieces fade out while in motion (default is true)
260                //              args.random: Float - If set, pieces fall in random order. The value defines how much
261                //                                                         randomness is introduced.
262                //              args.reverseOrder: Boolean - If true, pieces animate in reversed order
263                //              args.unhide: Boolean - If true, the peices fall from above and land in place
264                var node = args.node = dom.byId(args.node);
265
266                args.rows = args.rows || 5;
267                args.columns = args.columns || 5;
268                args.duration = args.duration || 1500;
269                args.interval = args.interval || args.duration / (args.rows + args.columns * 2);
270                args.distance = args.distance || 1.5;
271                args.random = args.random || 0;
272                if(typeof args.fade == "undefined"){
273                        args.fade = true;
274                }
275
276                var random = Math.abs(args.random),
277                        duration = args.duration - (args.rows + args.columns) * args.interval;
278
279                // Returns the animation object for each piece
280                args.pieceAnimation = function(piece, x, y, coords){
281
282                        var randomDelay = Math.random() * (args.rows + args.columns) * args.interval,
283                                ps = piece.style,
284
285                        // If distance is negative, start from the top right instead of bottom left
286                                uniformDelay = (args.reverseOrder || args.distance < 0) ?
287                                        ((x + y) * args.interval) :
288                                        (((args.rows + args.columns) - (x + y)) * args.interval),
289                                delay = randomDelay * random + Math.max(1 - random, 0) * uniformDelay,
290                        // Create the animation object for the piece
291                                properties = {}
292                        ;
293                        if(args.unhide){
294                                properties.top = {
295                                        start: (parseInt(ps.top) - coords.h * args.distance),
296                                        end: parseInt(ps.top)
297                                };
298                                if(args.fade){
299                                        properties.opacity = {start: "0", end: "1"};
300                                }
301                        }else{
302                                properties.top = {end: (parseInt(ps.top) + coords.h * args.distance)};
303                                if(args.fade){
304                                        properties.opacity = {end: "0"};
305                                }
306                        }
307                        var pieceAnimation = baseFx.animateProperty({
308                                node: piece,
309                                duration: duration,
310                                delay: delay,
311                                easing: (args.easing || (args.unhide ? easingUtil.sinIn : easingUtil.circIn)),
312                                properties: properties,
313                                beforeBegin: (args.unhide ? function(){
314                                        if(args.fade){
315                                                htmlUtil.style(piece, { opacity: "0" });
316                                        }
317                                        ps.top = properties.top.start + "px";
318                                } : undefined)
319                        });
320
321                        return pieceAnimation;
322                };
323
324                var anim = dojoxFx._split(args);
325                if(args.unhide){
326                        connectUtil.connect(anim, "onEnd", anim, function(){
327                                htmlUtil.style(node, { opacity: "1" });
328                        });
329                }else{
330                        connectUtil.connect(anim, "onPlay", anim, function(){
331                                htmlUtil.style(node, { opacity: "0" });
332                        });
333                }
334                return anim; // dojo.Animation
335        },
336
337        build: function(/*Object*/ args){
338                args.unhide = true;
339                return dojoxFx.disintegrate(args);
340        },
341
342        shear: function(/*Object*/ args){
343                // summary: Split a node into rectangular pieces and slide them in alternating directions
344                //
345                // description:
346                //              Returns an animation that will split the node into a grid
347                //              of pieces that slide in alternating directions.
348                //
349                //      args:
350                //              args.rows: Integer - The number of horizontal pieces (default is 6)
351                //              args.columns: Integer - The number of vertical pieces (default is 6)
352                //              args.interval: Float - The number of milliseconds between each piece's animation (default is 0)
353                //              args.distance: Float - The multiple of the node's dimensions to slide (default is 1)
354                //              args.fade: Boolean - If true, pieces fade out while in motion (default is true)
355                //              args.random: Float - If true, pieces have a random delay. The value defines how much
356                //                                                         randomness is introduced
357                //              args.reverseOrder: Boolean - If true, pieces animate in reversed order
358                //              args.unhide: Boolean - If true, the animation is reversed
359
360                var node = args.node = dom.byId(args.node);
361
362                args.rows = args.rows || 6;
363                args.columns = args.columns || 6;
364                args.duration = args.duration || 1000;
365                args.interval = args.interval || 0;
366                args.distance = args.distance || 1;
367                args.random = args.random || 0;
368                if(typeof(args.fade) == "undefined"){
369                        args.fade = true;
370                }
371                var random = Math.abs(args.random),
372                        duration = (args.duration - (args.rows + args.columns) * Math.abs(args.interval))
373                ;
374
375                // Returns the animation object for each piece
376                args.pieceAnimation = function(piece, x, y, coords){
377
378                        // Since x an y start at 0, the opposite is true...
379                        var colIsOdd = !(x % 2),
380                                rowIsOdd = !(y % 2),
381                                randomDelay = Math.random() * duration,
382                                uniformDelay = (args.reverseOrder) ?
383                                        (((args.rows + args.columns) - (x + y)) * args.interval) :
384                                        ((x + y) * args.interval),
385                                delay = randomDelay * random + Math.max(1 - random, 0) * uniformDelay,
386                                properties = {},
387                                ps = piece.style
388                        ;
389
390                        if(args.fade){
391                                properties.opacity = (args.unhide ? { start: "0", end: "1" } : { end: "0" });
392                        }
393
394                        // If we have only rows or columns, ignore the other dimension
395                        if(args.columns == 1){
396                                colIsOdd = rowIsOdd;
397                        }else if(args.rows == 1){
398                                rowIsOdd = !colIsOdd;
399                        }
400
401                        // Determine the piece's direction
402                        var left = parseInt(ps.left),
403                                top = parseInt(ps.top),
404                                distanceX = args.distance*coords.w,
405                                distanceY = args.distance*coords.h
406                        ;
407                        if(args.unhide){
408                                if(colIsOdd == rowIsOdd){
409                                        properties.left = colIsOdd ? {start: (left - distanceX), end: left} : {start: (left + distanceX), end: left};
410                                }else{
411                                        properties.top = colIsOdd ? {start: (top + distanceY), end: top} : {start: (top - distanceY), end: top};
412                                }
413                        }else{
414                                if(colIsOdd == rowIsOdd){
415                                        properties.left = colIsOdd ? {end: (left - distanceX)} : {end: (left + distanceX)};
416                                }else{
417                                        properties.top = colIsOdd ? {end: (top + distanceY)} : {end: (top - distanceY)};
418                                }
419                        }
420
421                        // Create the animation object for the piece
422                        var pieceAnimation = baseFx.animateProperty({
423                                node: piece,
424                                duration: duration,
425                                delay: delay,
426                                easing: (args.easing || easingUtil.sinInOut),
427                                properties: properties,
428                                beforeBegin: (args.unhide ? function(){
429                                        if(args.fade){
430                                                ps.opacity = "0";
431                                        }
432                                        if(colIsOdd == rowIsOdd){
433                                                ps.left = properties.left.start + "px";
434                                        }else{
435                                                ps.top = properties.top.start + "px";
436                                        }
437                                } : undefined)
438                        });
439
440                        return pieceAnimation;
441                };
442
443                var anim = dojoxFx._split(args);
444                if(args.unhide){
445                        connectUtil.connect(anim, "onEnd", anim, function(){
446                                htmlUtil.style(node, { opacity: "1" });
447                        });
448                }else{
449                        connectUtil.connect(anim, "onPlay", anim, function(){
450                                htmlUtil.style(node, { opacity: "0" });
451                        });
452                }
453                return anim; // dojo.Animation
454        },
455
456        unShear: function(/*Object*/ args){
457                args.unhide = true;
458                return dojoxFx.shear(args);
459        },
460
461        pinwheel: function(/*Object*/ args){
462                // summary: Split a node into rectangular pieces and wipe them in alternating directions
463                //
464                // description:
465                //              Returns an animation that will split the node into a grid
466                //              of pieces that wipe in alternating directions.
467                //
468                //      args:
469                //              args.rows: Integer - The number of horizontal pieces (default is 4)
470                //              args.columns: Integer - The number of vertical pieces (default is 4)
471                //              args.interval: Float - The number of milliseconds between each piece's animation (default is 0)
472                //              args.distance: Float - The percentage of the piece's dimensions the piece should wipe
473                //              args.fade: Boolean - If true, pieces fade out while in motion (default is true)
474                //              args.random: Float - If true, pieces have a random delay. The value defines how much
475                //                                                         randomness is introduced.
476                //              args.unhide: Boolean - If true, the animation is reversed
477
478                var node = args.node = dom.byId(args.node);
479
480                args.rows = args.rows || 4;
481                args.columns = args.columns || 4;
482                args.duration = args.duration || 1000;
483                args.interval = args.interval || 0;
484                args.distance = args.distance || 1;
485                args.random = args.random || 0;
486                if(typeof args.fade == "undefined"){
487                        args.fade = true;
488                }
489                var duration = (args.duration - (args.rows + args.columns) * Math.abs(args.interval));
490
491                // Returns the animation object for each piece
492                args.pieceAnimation = function(piece, x, y, coords){
493                        var pieceHeight = coords.h / args.rows,
494                                pieceWidth = coords.w / args.columns,
495
496                                // because x an y start at 0, the opposite is true...
497                                colIsOdd = !(x % 2),
498                                rowIsOdd = !(y % 2),
499
500                                randomDelay = Math.random() * duration,
501                                uniformDelay = (args.interval < 0) ?
502                                        (((args.rows + args.columns) - (x + y)) * args.interval * -1) :
503                                        ((x + y) * args.interval),
504                                delay = randomDelay * args.random + Math.max(1 - args.random, 0) * uniformDelay,
505                                properties = {},
506                                ps = piece.style
507                        ;
508
509                        if(args.fade){
510                                properties.opacity = (args.unhide ? {start: 0, end: 1} : {end:0});
511                        }
512
513                        // If we have only rows or columns, ignore the other dimension
514                        if(args.columns == 1){
515                                colIsOdd = !rowIsOdd;
516                        }else if(args.rows == 1){
517                                rowIsOdd = colIsOdd;
518                        }
519
520                        // Determine the piece's direction
521                        var left = parseInt(ps.left),
522                                top = parseInt(ps.top)
523                        ;
524                        if(colIsOdd){
525                                if(rowIsOdd){
526                                        properties.top = args.unhide ?
527                                                { start: top + pieceHeight * args.distance, end: top} :
528                                                { start: top, end: top + pieceHeight * args.distance} ;
529                                }else{
530                                        properties.left = args.unhide ?
531                                                { start: left + pieceWidth * args.distance, end: left } :
532                                                { start: left, end: left + pieceWidth * args.distance } ;
533                                }
534                        }
535                        if(colIsOdd != rowIsOdd){
536                                properties.width = args.unhide ?
537                                        { start: pieceWidth * (1 - args.distance), end: pieceWidth } :
538                                        { start: pieceWidth, end: pieceWidth * (1 - args.distance) } ;
539                        }else{
540                                properties.height = args.unhide ?
541                                        { start: pieceHeight * (1 - args.distance), end: pieceHeight } :
542                                        { start: pieceHeight, end: pieceHeight * (1 - args.distance) } ;
543                        }
544
545                        // Create the animation object for the piece
546                        var pieceAnimation = baseFx.animateProperty({
547                                node: piece,
548                                duration: duration,
549                                delay: delay,
550                                easing: (args.easing || easingUtil.sinInOut),
551                                properties: properties,
552                                beforeBegin: (args.unhide ? function(){
553                                        if(args.fade){
554                                                htmlUtil.style(piece, "opacity", 0);
555                                        }
556                                        if(colIsOdd){
557                                                if(rowIsOdd){
558                                                        ps.top = (top + pieceHeight * (1 - args.distance)) + "px";
559                                                }else{
560                                                        ps.left = (left + pieceWidth * (1 - args.distance)) + "px";
561                                                }
562                                        }else{
563                                                ps.left = left + "px";
564                                                ps.top = top + "px";
565                                        }
566                                        if(colIsOdd != rowIsOdd){
567                                                ps.width = (pieceWidth * (1 - args.distance)) + "px";
568                                        }else{
569                                                ps.height = (pieceHeight * (1 - args.distance)) + "px";
570                                        }
571                                } : undefined)
572                        });
573
574                        return pieceAnimation;
575                };
576
577                var anim = dojoxFx._split(args);
578                if(args.unhide){
579                        connectUtil.connect(anim, "onEnd", anim, function(){
580                                htmlUtil.style(node, { opacity: "1" });
581                        });
582                }else{
583                        connectUtil.connect(anim, "play", anim, function(){
584                                htmlUtil.style(node, { opacity: "0" });
585                        });
586                }
587                return anim; // dojo.Animation
588        },
589
590        unPinwheel: function(/*Object*/ args){
591                args.unhide = true;
592                return dojoxFx.pinwheel(args); // dojo.Animation
593        },
594
595        blockFadeOut: function(/*Object*/ args){
596                // summary: Split a node into rectangular pieces and fade them
597                //
598                // description:
599                //              Returns an animation that will split the node into a grid
600                //              of pieces that fade in or out.
601                //
602                //      args:
603                //              args.rows: Integer - The number of horizontal pieces (default is 5)
604                //              args.columns: Integer - The number of vertical pieces (default is 5)
605                //              args.interval: Float - The number of milliseconds between each piece's animation (default is 0)
606                //              args.random: Float - If true, pieces have a random delay. The value defines how much
607                //                                                         randomness is introduced
608                //              args.reverseOrder: Boolean - If true, pieces animate in reversed order
609                //              args.unhide: Boolean - If true, the animation is reversed
610
611                var node = args.node = dom.byId(args.node);
612
613                args.rows = args.rows || 5;
614                args.columns = args.columns || 5;
615                args.duration = args.duration || 1000;
616                args.interval = args.interval || args.duration / (args.rows + args.columns * 2);
617                args.random = args.random || 0;
618                var random = Math.abs(args.random),
619                        duration = args.duration - (args.rows + args.columns) * args.interval
620                ;
621
622                // Returns the animation object for each piece
623                args.pieceAnimation = function(piece, x, y, coords){
624                        var randomDelay = Math.random() * args.duration,
625                                uniformDelay = (args.reverseOrder) ?
626                                        (((args.rows + args.columns) - (x + y)) * Math.abs(args.interval)) :
627                                        ((x + y) * args.interval),
628                                delay = randomDelay * random + Math.max(1 - random, 0) * uniformDelay,
629                        // Create the animation object for the piece
630                                pieceAnimation = baseFx.animateProperty({
631                                        node: piece,
632                                        duration: duration,
633                                        delay: delay,
634                                        easing: (args.easing || easingUtil.sinInOut),
635                                        properties: {
636                                                opacity: (args.unhide ? {start: "0", end: "1"} : {start: "1", end: "0"})
637                                        },
638                                        beforeBegin: (args.unhide ? function(){ htmlUtil.style(piece, { opacity: "0" });} : function(){ piece.style.filter = ""; })
639                                });
640
641                        return pieceAnimation;
642                };
643                var anim = dojoxFx._split(args);
644                if(args.unhide){
645                        connectUtil.connect(anim, "onEnd", anim, function(){
646                                htmlUtil.style(node, { opacity: "1" });
647                        });
648                }else{
649                        connectUtil.connect(anim, "onPlay", anim, function(){
650                                htmlUtil.style(node, { opacity: "0" });
651                        });
652                }
653                return anim; // dojo.Animation
654        },
655
656        blockFadeIn: function(/*Object*/ args){
657                args.unhide = true;
658                return dojoxFx.blockFadeOut(args); // dojo.Animation
659        }
660});
661return fxExt;
662});
Note: See TracBrowser for help on using the repository browser.