mootools/mootools-core — Issue #2111: setStyle('opacity',...) does not update visibility
Author: gajdusek
Created: 2011-10-22 15:13:22+00:00
State: open

Hello,

I have just upgraded to mootools 1.4.1 and have realized that now, unlike 1.3.x, when I set opacity, the visibility property is not updated.
I do not know if this is intended or not, but as 1.4.1 returned this functionality (only) to element.fade(), I guess the later.

Maybe this should go into element.setStyle() so compatibility with 1.3.x is preserved or the change should be documented somewhere.

Cheers, Petr

-1.4.1-full-nocompat.js mootools-core-1.4.1-full-nocompat.js
--- /tmp/mootools-core-1.4.1-full-nocompat.js	2011-10-22 16:59:36.792611922 +0200
+++ mootools-core-1.4.1-full-nocompat.js	2011-10-22 16:59:20.472598472 +0200
@@ -3634,6 +3634,10 @@

setStyle: function(property, value){
if (property == 'opacity'){
+	var visibility = this.style.visibility;
+	if (value == 0 && visibility != 'hidden') this.style.visibility = 'hidden';
+	else if (value != 0 && visibility != 'visible') this.style.visibility = 'visible';
+
setOpacity(this, parseFloat(value));
return this;
}
@@ -4822,10 +4826,6 @@
}
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;
},