Subversion Repositories wimsdev

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
/*
2
        DynAPI Distribution
3
        Fader Animation Extension
4
 
5
        The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
6
 
7
        requires: DynLayer
8
*/
9
 
10
Fader = {}; // used by dynapi.library
11
 
12
DynLayer.prototype._fadeMode = '';
13
DynLayer.prototype.fadeIn = function(inc,ms){
14
        this._opacity=0;
15
        this._fadeMode='in';
16
        this.fadeTo(100,(inc||4),ms);
17
};
18
DynLayer.prototype.fadeOut = function(inc,ms){
19
        this._opacity=100;
20
        this._fadeMode='out';
21
        this.fadeTo(0,inc||4,ms);
22
};
23
// Fades an object to "opacity" by "inc" increments in every "ms" millisenconds
24
DynLayer.prototype.fadeTo = function(opacity,inc,ms){
25
        if(this._opacity==null) this._opacity=100;
26
        inc=(inc)? Math.abs(inc):5;
27
        this._fadeMs=(ms)? ms:50;
28
        if (this._opacity>opacity) inc*=-1;
29
        this._fadeInc=inc;
30
        this._fadeToOpacity = opacity;
31
        this._fadeTimeout=window.setTimeout(this+'._fade()',this._fadeMs);
32
};
33
DynLayer.prototype._fade = function(){
34
        var ua=dynapi.ua;
35
        var fm=this._fadeMode;
36
        var inc = this._fadeInc;
37
        var opac = this._opacity;
38
        var fopac = this._fadeToOpacity;
39
        opac+=inc;
40
        if ((inc<0 && opac<=fopac)|| (inc>0 && opac>=fopac)) opac=fopac;
41
        this._opacity=opac;
42
        if(!ua.def) this.setVisible((opac>0)? true:false);
43
        else if(ua.dom && this.css){
44
                if(opac>1 && this.visible==false) this.setVisible(true);
45
                if(ua.ie) this.css.filter='alpha(opacity=' + opac + ')';
46
                else this.css.MozOpacity = parseInt(opac)/100;
47
        }
48
        if(opac!=fopac) this._fadeTimeout=window.setTimeout(this+'._fade()',this._fadeMs);
49
        else {
50
                this._fadeMode='';
51
                window.clearTimeout(this._fadeTimeout);
52
                this.invokeEvent('fade'+fm);
53
 
54
        }
55
};