I was wondering why this code crash my browser:
while (true) {
$('.selector')
.animate({ 'bottom': '30px' }, 500)
.animate({ 'bottom' : '20px' }, 500);
}
and this other code works (without true as a condition)
var a = 0;
while (a < 1000) {
$('.selector')
.animate({ 'bottom': '30px' }, 500)
.animate({ 'bottom' : '20px' }, 500);
a++;
}
If i would dare to answer the question myself i'd say that the second code fill a queue of 1000 actions and stops when the first one never finishes and crash the browser.
I need it to be infinite but not going to the next iteration until the animations are complete. I was playing with stop();
here and there but it didn't do the trick.