Make sure opacity is a float and rounded

This commit is contained in:
Dávid Szabó 2016-08-26 01:40:56 +02:00 committed by Julian Descottes
parent 0c0aa5f2c9
commit 7eab386122

View File

@ -37,10 +37,13 @@
}; };
ns.Layer.prototype.setOpacity = function (opacity) { ns.Layer.prototype.setOpacity = function (opacity) {
if (typeof opacity == 'string') {
opacity = parseFloat(opacity);
}
if (opacity === null || isNaN(opacity) || opacity < 0 || opacity > 1) { if (opacity === null || isNaN(opacity) || opacity < 0 || opacity > 1) {
return; return;
} }
this.opacity = opacity; this.opacity = +opacity.toFixed(3);
}; };
ns.Layer.prototype.isTransparent = function () { ns.Layer.prototype.isTransparent = function () {