I have an animation that when one part is finished the other is started and it can be very long queue.
I put the code here: https://jsfiddle.net/homa/qub7ejd1/
As you can see to have the queue, I have this code:
newMessage('HA HA HA HA ....').onfinish = function () {
newMessage('Don\'t tell anybody I am here....').onfinish = function () {
newMessage('<b>PLEAAAASEEE</b>').onfinish = function () {
newMessage('I was very hungry...').onfinish = function () {
newMessage('Hello');
}
}
}
};
My code gets really really ugly as it gradually gets long. Also when I have if else to run a specific animation in queue, it hardly is readable.
Do you have any suggestion to solve this problem?