source: Dev/branches/rest-dojo-ui/client/dojox/app/transition.js @ 274

Last change on this file since 274 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: 2.1 KB
Line 
1define(["dojo/_base/kernel", "dojo/_base/array","dojo/_base/html","dojo/DeferredList","./animation"],
2        function(dojo, darray, dhtml, DeferredList,animation){
3        return function(from, to, options){
4                var rev = (options && options.reverse) ? -1 : 1;
5                if(!options || !options.transition || !animation[options.transition]){
6                        dojo.style(from,"display","none");
7                        dojo.style(to, "display", "");
8                        if(options.transitionDefs){
9                            if(options.transitionDefs[from.id]){
10                                options.transitionDefs[from.id].resolve(from);
11                            }
12                            if(options.transitionDefs[to.id]){
13                                options.transitionDefs[to.id].resolve(to);
14                            }
15                        }
16                }else{
17                        var defs=[];
18                        var transit=[];
19                        var duration = 250;
20                        if(options.transition === "fade"){
21                            duration = 600;
22                        }else if (options.transition === "flip"){
23                            duration = 200;
24                        }
25                        dojo.style(from, "display", "");
26                        dojo.style(to, "display", "");
27                        if (from){
28                                //create animation to transit "from" out
29                                var fromTransit = animation[options.transition](from, {
30                                    "in": false,
31                                    direction: rev,
32                                    duration: duration,
33                                    deferred: (options.transitionDefs && options.transitionDefs[from.id]) ? options.transitionDefs[from.id] : null
34                                });
35                                defs.push(fromTransit.deferred);//every animation object should have a deferred.
36                                transit.push(fromTransit);
37                        }
38                       
39                        //create animation to transit "to" in                   
40                        var toTransit = animation[options.transition](to, {
41                            direction: rev,
42                            duration: duration,
43                            deferred: (options.transitionDefs && options.transitionDefs[to.id]) ? options.transitionDefs[to.id] : null
44                        });
45                        defs.push(toTransit.deferred);//every animation object should have a deferred.
46                        transit.push(toTransit);
47                       
48                        //TODO If it is flip use the chainedPlay
49                        //play fromTransit and toTransit together
50                        if(options.transition === "flip"){
51                            animation.chainedPlay(transit);
52                        }else{
53                            animation.groupedPlay(transit);
54                        }
55
56                        return new dojo.DeferredList(defs);
57                       
58                }
59        };
60});
Note: See TracBrowser for help on using the repository browser.