😡
i’m stumped as to why the following code performs properly fading out, but when the opacity reaches 0 the browser refreshes the image to full opacity and does a quick, unwanted additional 10-second fade out before it fades in properly. it feels as if there’s a mis-match between the setInterval time and the interval used inside my function.
[U]the function:
[INDENT]var direction = “down”;
var tIncrement = 90;
function fader() {
var theImg = document.getElementById(“mainImg”);
if (direction == “down”) {
tIncrement–;
} else if (direction == “up”) {
tIncrement++;
}
if (tIncrement < 100 && tIncrement > 0)
theImg.setAttribute(“style”, “opacity: .” + tIncrement);
else
theImg.setAttribute(“style”, “opacity: ” + tIncrement);
if (tIncrement < 1/100) direction = “up”;
else if (theImg.style.opacity > 1-1/100) direction = “down”;
};
[/INDENT]
[U]the call:
[INDENT]<body onload=”setInterval(‘fader()’, 100);”>[/INDENT]
any help would be enormously appreciated.