Permalink
Browse files

Fixes #2074 - Element.fade set the visibility to hidden again when th…

…e element is entirely faded out
  • Loading branch information...
1 parent fd1d6ce commit 11b4257f12a51454bd513ab1ac32cd5239d66098 @arian arian committed with cpojer Sep 20, 2011
Showing with 16 additions and 10 deletions.
  1. +15 −9 Source/Fx/Fx.Tween.js
  2. +1 −1 Specs
View
@@ -63,27 +63,33 @@ Element.Properties.tween = {
Element.implement({
tween: function(property, from, to){
- this.get('tween').start(arguments);
+ this.get('tween').start(property, from, to);
return this;
},
fade: function(how){
- var fade = this.get('tween'), o = 'opacity', toggle;
- how = [how, 'toggle'].pick();
+ var fade = this.get('tween'), method, to, toggle;
+ if (how == null) how = 'toggle';
switch (how){
- case 'in': fade.start(o, 1); break;
- case 'out': fade.start(o, 0); break;
- case 'show': fade.set(o, 1); break;
- case 'hide': fade.set(o, 0); break;
+ case 'in': method = 'start'; to = 1; break;
+ case 'out': method = 'start'; to = 0; break;
+ case 'show': method = 'set'; to = 1; break;
+ case 'hide': method = 'set'; to = 0; break;
case 'toggle':
var flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);
- fade.start(o, (flag) ? 0 : 1);
+ method = 'start';
+ to = flag ? 0 : 1;
this.store('fade:flag', !flag);
toggle = true;
break;
- default: fade.start(o, arguments);
+ default: method = 'start'; to = how;
}
if (!toggle) this.eliminate('fade:flag');
+ fade[method]('opacity', to);
+ if (method == 'set' || to != 0) this.setStyle('visibility', to == 0 ? 'hidden' : 'visible');
+ else fade.chain(function(){
+ this.element.setStyle('visibility', 'hidden');
+ });
return this;
},

0 comments on commit 11b4257

Please sign in to comment.