Animate multiple times

You must Login before you can answer or comment on any questions.

Hi all,

I have two views that I want to animate multiple time. From left to right. This is my code inside a interval:

if (counter % 5 == 0) {
        if (i == 0) {
            alert('LEFT');
            x.animate({
                left : 5,
                duration : 500
            });
            y.animate({
                left : 5,
                duration : 500
            });
            i = 1;
        } else {
            alert('RIGHT');
            x.animate({
                right : 5,
                duration : 500
            });
            y.animate({
                right : 5,
                duration : 500
            });
            i = 0;
        }
    }
    counter++;
When I test this code, it doesn't work. It reaches the alerts, but it doesn't work after the first animation.

So, when I start this code, I get the alert 'LEFT' and the views move to left, and after that I only get alerts 'RIGHT', 'LEFT' etc without animations.

What is my mistake?

Regards, Marc

Your Answer

Think you can help? Login to answer this question!