]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/ytree/TreeView/anim/TVFadeIn.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / ytree / TreeView / anim / TVFadeIn.js
1 /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
2
3 /**
4  * A 1/2 second fade-in animation.
5  *
6  * @constructor
7  * @param el {HTMLElement} the element to animate
8  * @param callback {function} function to invoke when the animation is finished
9  */
10 YAHOO.widget.TVFadeIn = function(el, callback) {
11         /**
12          * The element to animate
13      * @type HTMLElement
14          */
15         this.el = el;
16
17         /**
18          * the callback to invoke when the animation is complete
19          *
20          * @type function
21          */
22         this.callback = callback;
23
24         /**
25          * @private
26          */
27         this.logger = new ygLogger("TVFadeIn");
28 };
29
30 /**
31  * Performs the animation
32  */
33 YAHOO.widget.TVFadeIn.prototype = {
34     animate: function() {
35         var tvanim = this;
36
37         var s = this.el.style;
38         s.opacity = 0.1;
39         s.filter = "alpha(opacity=10)";
40         s.display = "";
41
42         // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
43         var dur = 0.4; 
44         // this.logger.debug("duration: " + dur);
45         // var a = new ygAnim_Fade(this.el, dur, 1);
46         // a.setStart(0.1);
47         // a.onComplete = function() { tvanim.onComplete(); };
48
49         // var a = new YAHOO.util.Anim(this.el, 'opacity', 0.1, 1);
50         var a = new YAHOO.util.Anim(this.el, {opacity: {from: 0.1, to: 1, unit:""}}, dur);
51         a.onComplete.subscribe( function() { tvanim.onComplete(); } );
52         a.animate();
53     },
54
55     /**
56      * Clean up and invoke callback
57      */
58     onComplete: function() {
59         this.callback();
60     }
61 };
62