I'm new to Javascript, please bear with me.
I have a code similar to the one below, whenever I click a button, it performs some animation on a HTML element, problem is, if the user clicks multiple times, the animation will be buffered and executed with a huge delay all at once.
The code below "should" solve the problem by disabling the loop until the animation completes, but it doesn't. I can not change the code's structure too much, it must stay in this form more or less.
var processing = false;
$("p").click(function() {
if (processing == false) {
for (i=0; i<5; i++) {
if (processing == false)
processing = true;
tastor();
}
processing = false;
}
});
function tastor() {
zubi = parseFloat($('p').css('font-size'));
$('p').animate({'font-size': zubi+i}, 500);
}