inside my demo function , i have a fadeout function. this function animate an image by fading it out and it runs for few seconds.
i want an alert to run only after this fading is completed. . it's not working this way. the alert is popping out before the fading is completed.
is there any way to sequence it beside calculating the runtime of each function and creating accordingly setTimeout for each command?
the Demo function:
function Demo() {
fadeout(liran0);
alert("hello");
}
the fadeout function is needed for analysis:
function fadeout(element) {
var op = 1; // initial opacity
var timer = setInterval(function () { //call the function every x milliseconds
if (op <= 0.01) { // stop the function when the op is lower then 0.1 and then make in invisible.
element.style.opacity = 0; // make it invisible
clearInterval(timer); // clear the timer ....
return true;
}
element.style.opacity = op;
op -= 0.01;
}, 10);
}