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
8 if(!dojo._hasResource["dojo._base.fx"]){
9 dojo._hasResource["dojo._base.fx"]=true;
10 dojo.provide("dojo._base.fx");
11 dojo.require("dojo._base.Color");
12 dojo.require("dojo._base.connect");
13 dojo.require("dojo._base.lang");
14 dojo.require("dojo._base.html");
18 dojo._Line=function(_2,_3){
22 dojo._Line.prototype.getValue=function(n){
23 return ((this.end-this.start)*n)+this.start;
25 dojo.Animation=function(_4){
27 if(d.isArray(this.curve)){
28 this.curve=new d._Line(this.curve[0],this.curve[1]);
31 d._Animation=d.Animation;
32 d.extend(dojo.Animation,{duration:350,repeat:0,rate:20,_percent:0,_startRepeatCount:0,_getStep:function(){
33 var _5=this._percent,_6=this.easing;
35 },_fire:function(_7,_8){
38 if(d.config.debugAtAllCosts){
39 this[_7].apply(this,a);
42 this[_7].apply(this,a);
45 console.error("exception in animation handler for:",_7);
51 },play:function(_9,_a){
58 _b._active=_b._paused=false;
61 if(_b._active&&!_b._paused){
65 _b._fire("beforeBegin",[_b.node]);
66 var de=_9||_b.delay,_c=dojo.hitch(_b,"_play",_a);
68 _b._delayTimer=setTimeout(_c,de);
78 _e._startTime=new Date().valueOf();
80 _e._startTime-=_e.duration*_e._percent;
84 var _f=_e.curve.getValue(_e._getStep());
86 if(!_e._startRepeatCount){
87 _e._startRepeatCount=_e.repeat;
89 _e._fire("onBegin",[_f]);
91 _e._fire("onPlay",[_f]);
104 _10._fire("onPause",[_10.curve.getValue(_10._getStep())]);
106 },gotoPercent:function(_11,_12){
109 _13._active=_13._paused=true;
115 },stop:function(_14){
127 _15._fire("onStop",[_15.curve.getValue(_15._getStep())]);
128 _15._active=_15._paused=false;
132 return this._paused?"paused":"playing";
138 var _17=new Date().valueOf();
139 var _18=(_17-_16._startTime)/(_16.duration);
147 _16._fire("onAnimate",[_16.curve.getValue(_18)]);
159 if(_16._startRepeatCount){
160 _16.repeat=_16._startRepeatCount;
161 _16._startRepeatCount=0;
166 _16._fire("onEnd",[_16.node]);
167 !_16.repeat&&_16._stopTimer();
171 },_clearTimer:function(){
172 clearTimeout(this._delayTimer);
173 delete this._delayTimer;
175 var ctr=0,_19=null,_1a={run:function(){
177 d.extend(d.Animation,{_startTimer:function(){
179 this._timer=d.connect(_1a,"run",this,"_cycle");
183 _19=setInterval(d.hitch(_1a,"run"),this.rate);
185 },_stopTimer:function(){
187 d.disconnect(this._timer);
197 var _1b=d.isIE?function(_1c){
199 if(!ns.width.length&&d.style(_1c,"width")=="auto"){
204 dojo._fade=function(_1d){
205 _1d.node=d.byId(_1d.node);
206 var _1e=_1({properties:{}},_1d),_1f=(_1e.properties.opacity={});
207 _1f.start=!("start" in _1e)?function(){
208 return +d.style(_1e.node,"opacity")||0;
211 var _20=d.animateProperty(_1e);
212 d.connect(_20,"beforeBegin",d.partial(_1b,_1e.node));
215 dojo.fadeIn=function(_21){
216 return d._fade(_1({end:1},_21));
218 dojo.fadeOut=function(_22){
219 return d._fade(_1({end:0},_22));
221 dojo._defaultEasing=function(n){
222 return 0.5+((Math.sin((n+1.5)*Math.PI))/2);
224 var _23=function(_24){
225 this._properties=_24;
228 if(_25.start instanceof d.Color){
229 _25.tempColor=new d.Color();
233 _23.prototype.getValue=function(r){
235 for(var p in this._properties){
236 var _26=this._properties[p],_27=_26.start;
237 if(_27 instanceof d.Color){
238 ret[p]=d.blendColors(_27,_26.end,r,_26.tempColor).toCss();
241 ret[p]=((_26.end-_27)*r)+_27+(p!="opacity"?_26.units||"px":0);
247 dojo.animateProperty=function(_28){
248 var n=_28.node=d.byId(_28.node);
250 _28.easing=d._defaultEasing;
252 var _29=new d.Animation(_28);
253 d.connect(_29,"beforeBegin",_29,function(){
255 for(var p in this.properties){
256 if(p=="width"||p=="height"){
257 this.node.display="block";
259 var _2a=this.properties[p];
260 if(d.isFunction(_2a)){
263 _2a=pm[p]=_1({},(d.isObject(_2a)?_2a:{end:_2a}));
264 if(d.isFunction(_2a.start)){
265 _2a.start=_2a.start(n);
267 if(d.isFunction(_2a.end)){
270 var _2b=(p.toLowerCase().indexOf("color")>=0);
272 var v={height:_2d.offsetHeight,width:_2d.offsetWidth}[p];
277 return (p=="opacity")?+v:(_2b?v:parseFloat(v));
282 if(!("start" in _2a)){
287 _2a.start=new d.Color(_2a.start);
288 _2a.end=new d.Color(_2a.end);
290 _2a.start=(p=="opacity")?+_2a.start:parseFloat(_2a.start);
293 this.curve=new _23(pm);
295 d.connect(_29,"onAnimate",d.hitch(d,"style",_29.node));
298 dojo.anim=function(_2e,_2f,_30,_31,_32,_33){
299 return d.animateProperty({node:_2e,duration:_30||d.Animation.prototype.duration,properties:_2f,easing:_31,onEnd:_32}).play(_33||0);