root / trunk / web / dojo / dojox / widget / rotator / Pan.js
History | View | Annotate | Download (1.85 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.widget.rotator.Pan"]){ |
9 |
dojo._hasResource["dojox.widget.rotator.Pan"]=true; |
10 |
dojo.provide("dojox.widget.rotator.Pan");
|
11 |
dojo.require("dojo.fx");
|
12 |
(function(d){
|
13 |
var _1=0,_2=1,UP=2,_3=3; |
14 |
function _4(_5,_6){ |
15 |
var n=_6.next.node,r=_6.rotatorBox,m=_5%2,a=m?"left":"top",s=(m?r.w:r.h)*(_5<2?-1:1),p={},q={}; |
16 |
d.style(n,"display",""); |
17 |
p[a]={start:0,end:-s}; |
18 |
q[a]={start:s,end:0}; |
19 |
return d.fx.combine([d.animateProperty({node:_6.current.node,duration:_6.duration,properties:p,easing:_6.easing}),d.animateProperty({node:n,duration:_6.duration,properties:q,easing:_6.easing})]); |
20 |
}; |
21 |
function _7(n,z){ |
22 |
d.style(n,"zIndex",z);
|
23 |
}; |
24 |
d.mixin(dojox.widget.rotator,{pan:function(_8){ |
25 |
var w=_8.wrap,p=_8.rotator.panes,_9=p.length,z=_9,j=_8.current.idx,k=_8.next.idx,nw=Math.abs(k-j),ww=Math.abs((_9-Math.max(j,k))+Math.min(j,k))%_9,_a=j<k,_b=_3,_c=[],_d=[],_e=_8.duration;
|
26 |
if((!w&&!_a)||(w&&(_a&&nw>ww||!_a&&nw<ww))){
|
27 |
_b=_2; |
28 |
} |
29 |
if(_8.continuous){
|
30 |
if(_8.quick){
|
31 |
_e=Math.round(_e/(w?Math.min(ww,nw):nw)); |
32 |
} |
33 |
_7(p[j].node,z--); |
34 |
var f=(_b==_3);
|
35 |
while(1){ |
36 |
var i=j;
|
37 |
if(f){
|
38 |
if(++j>=_9){
|
39 |
j=0;
|
40 |
} |
41 |
}else{
|
42 |
if(--j<0){ |
43 |
j=_9-1;
|
44 |
} |
45 |
} |
46 |
var x=p[i],y=p[j];
|
47 |
_7(y.node,z--); |
48 |
_c.push(_4(_b,d.mixin({easing:function(m){ |
49 |
return m;
|
50 |
}},_8,{current:x,next:y,duration:_e}))); |
51 |
if((f&&j==k)||(!f&&j==k)){
|
52 |
break;
|
53 |
} |
54 |
_d.push(y.node); |
55 |
} |
56 |
var _f=d.fx.chain(_c),h=d.connect(_f,"onEnd",function(){ |
57 |
d.disconnect(h); |
58 |
d.forEach(_d,function(q){
|
59 |
d.style(q,{display:"none",left:0,opacity:1,top:0,zIndex:0}); |
60 |
}); |
61 |
}); |
62 |
return _f;
|
63 |
} |
64 |
return _4(_b,_8);
|
65 |
},panDown:function(_10){ |
66 |
return _4(_1,_10);
|
67 |
},panRight:function(_11){ |
68 |
return _4(_2,_11);
|
69 |
},panUp:function(_12){ |
70 |
return _4(UP,_12);
|
71 |
},panLeft:function(_13){ |
72 |
return _4(_3,_13);
|
73 |
}}); |
74 |
})(dojo); |
75 |
} |