]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/ytree/TreeView/anim/TVFadeOut.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / ytree / TreeView / anim / TVFadeOut.js
1 /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
2
3 /**
4  * A 1/2 second fade out 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.TVFadeOut = 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("TVFadeOut");
28 };
29
30 /**
31  * Performs the animation
32  */
33 YAHOO.widget.TVFadeOut.prototype = {
34     animate: function() {
35         var tvanim = this;
36         // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
37         var dur = 0.4;
38         // this.logger.debug("duration: " + dur);
39         // var a = new ygAnim_Fade(this.el, dur, 0.1);
40         // a.onComplete = function() { tvanim.onComplete(); };
41
42         // var a = new YAHOO.util.Anim(this.el, 'opacity', 1, 0.1);
43         var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur);
44         a.onComplete.subscribe( function() { tvanim.onComplete(); } );
45         a.animate();
46     },
47
48     /**
49      * Clean up and invoke callback
50      */
51     onComplete: function() {
52         var s = this.el.style;
53         s.display = "none";
54         // s.opacity = 1;
55         s.filter = "alpha(opacity=100)";
56         this.callback();
57     }
58 };
59