1 year ago

#385305

test-img

Rob_lc

How to loop an animation without a maximum call back error jQuery?

I am trying to animate these two shapes up and down but only the first shape will animate and the other one won't and I get a "Maximum call stack exceeded error"

JavaScript function

function loopAnimation(shape, cssProperty, moveVal) {
            $(shape)
            .animate({[cssProperty]: "+=" + moveVal}, 1000)
            .animate({[cssProperty]: "-=" + moveVal}, 1000)
            loopAnimation(shape, cssProperty, moveVal);
        };

Function call

loopAnimation(cube, "top", "75%");
loopAnimation(triangle, "bottom", "75%");

javascript

jquery

css

css-animations

jquery-animate

0 Answers

Your Answer

Accepted video resources