source: Dev/branches/rest-dojo-ui/client/dojox/css3/transit.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: 2.0 KB
Line 
1define(["dojo/_base/kernel", "dojo/_base/array","dojo/dom-style","dojo/DeferredList","./transition"],
2        function(dojo, darray, domStyle, DeferredList,transition){
3        var transit =  function(from, to, options){
4                var rev = (options && options.reverse) ? -1 : 1;
5                if(!options || !options.transition || !transition[options.transition]){
6                        domStyle.set(from,"display","none");
7                        domStyle.set(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                        domStyle.set(from, "display", "");
26                        domStyle.set(to, "display", "");
27                        if (from){
28                                //create transition to transit "from" out
29                                var fromTransit = transition[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 transition object should have a deferred.
36                                transit.push(fromTransit);
37                        }
38                       
39                        //create transition to transit "to" in                                 
40                        var toTransit = transition[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 transition 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                                transition.chainedPlay(transit);
52                        }else{
53                                transition.groupedPlay(transit);
54                        }
55
56                        return new DeferredList(defs);
57                       
58                }
59        };
60       
61        return transit;
62});
Note: See TracBrowser for help on using the repository browser.