这有什么问题? parseFloat只返回0,但仍然在字符串中" 0.9"
答案 0 :(得分:-1)
是的,看起来我在区间内没有正确编码并且这给出了错误的结果所以我更改了代码以便拥有更好的逻辑并且现在它可以工作。这是结果代码:
var FaderElement = (function () {
function FaderElement() {
}
FaderElement.prototype.FadeOutElement = function (id, Min) {
var Element = document.getElementById(id);
var currentOpacity;
clearInterval(this._intervalin);
this._intervalout = setInterval(function () {
currentOpacity = parseFloat(Element.currentStyle.opacity);
if (currentOpacity > Min) {
currentOpacity -= 0.1;
Element.style.opacity = currentOpacity.toString();
}
else {
clearInterval(this.intervalout);
}
}, 33);
};
FaderElement.prototype.FadeInElement = function (id, Max) {
var Element = document.getElementById(id);
var currentOpacity;
clearInterval(this._intervalout);
this._intervalin = setInterval(function () {
currentOpacity = parseFloat(Element.currentStyle.opacity);
if (currentOpacity < Max) {
currentOpacity += 0.1;
Element.style.opacity = currentOpacity.toString();
}
else {
clearInterval(this.intervalin);
}
}, 33);
};
return FaderElement;
})();