I have this function that I wrote that is supposed to display notifications:
function newNotification(message) {
window.clearTimeout(window.tid);
$("#notify").stop().prepend(message + '<br/>').fadeIn(400, function() {
window.tid = window.setTimeout(function() {
$("#notify").fadeOut('3000', function() {
$("#notify").html('');
});
}, 3000);
});
}
The problem is that if I pass a notification while another is fading out the #notify div doesn’t fade back in. Its opacity gets stuck between 0 and 1.
Can anyone please help?
Ok, so I finally managed to figure it out.
FadeIn()only works if the element is hidden, that’s why it gets stuck when the opacity is between 0 and 1.I just had to replace
FadeIn()withFadeTo()to make it work.Thanks for your help everyone!