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?