Moin.
Eine Idee, wo ich ansetzen soll?
Verwende einen einzigen Timer per setInterval()
:
onload = function() {
var timer = false,
foo = document.getElementById('foo'),
pic = document.getElementById('fadein'),
opacity = 0;
function setOpacity(elm, value) {
elm.style.opacity = value / 100;
elm.style.filter = 'Alpha(opacity=' + value + ')'
}
function clear() {
if(timer !== false) {
clearInterval(timer);
timer = false;
}
}
function fadeIn() {
if(opacity < 100)
setOpacity(pic, ++opacity);
else clear();
}
function fadeOut() {
if(opacity > 0)
setOpacity(pic, --opacity);
else clear();
}
foo.onmouseover = function() {
clear();
timer = setInterval(fadeIn, 9);
};
foo.onmouseout = function() {
clear();
timer = setInterval(fadeOut, 5);
};
// brauchen wir, da style="opacity: 1;"
setOpacity(pic, 0);
};
Christoph