While working on a text-blinking code, I discovered that under certain timing conditions, the following code can cause the text to remain hidden even after the animation has stopped:
//Blink settings
var blink = {
obj: $(".blink"),
timeout: 15000,
speed: 1000
};
//Start function
blink.fn = setInterval(function () {
blink.obj.fadeToggle(blink.speed);
}, blink.speed + 100);
//End blink animation, after 'blink.timeout' milliseconds
setTimeout(function () {
clearInterval(blink.fn);
blink = null;
}, blink.timeout);
Attempts were made to resolve this issue by adding blink.obj.show()
, blink.obj.css(...)
etc. immediately after clearInterval(blink.fn);
, however, it was not successful.
...
setTimeout(function () {
clearInterval(blink.fn);
blink.obj.show();
blink.obj.css("visibility","visible");
...
My goal is to ensure that the text is ALWAYS visible once the blinking stops