Animate () only works on the first transition

1

I'm creating an infinite carousel that should be animated between transitions, but the .animate() event only works on the first transition, the rest is completely static, with no animation.

Code:

var next = function(){
    var left = parseInt(ul.css('left')) - (size + rest + settings.margin);

    ul.stop(true, true).animate({'left' : left}, settings.speed, function(){
        $('> li:last', ul).after($('> li:first', ul));
        ul.css({'left' : (size + rest + settings.margin) * (-1)});
    });

    return false;
}

var transition = null;

var init = function(){
    transition = setInterval(function(){
        next();
    }, settings.delay)
};

init();

Note: If I remove the fix .css() from the position, the carousel stays animated, but logically the ul will be going left until it disappears.

What's wrong?

    
asked by anonymous 01.07.2015 / 07:01

0 answers