I'm starting my jQuery studies. I am having difficulties making a continuous slide animation, with images of some clients passing by the screen. Everything is good until I try to PAUSE the function when the user passes the mouse over the <ul>
that is passing. When this occurs, the animation stops. But to restart, it takes a short delay (even with the .clearQueue();
) this short delay remains. how do I correct this to eliminate the delay?
The function:
animar('.clientesHome ul');
// pauses / iniciate animation
$('.clientesHome ul').hover(
function () {
$('.clientesHome ul').clearQueue();
$('.clientesHome ul').stop();
},
function () {
$('.clientesHome ul').clearQueue();
animar('.clientesHome ul');
}
);
function animar(oque) {
if(!stoped){
$(oque).css('left', $(oque).position().left);
$(oque).clearQueue();
var regressivo = 2000;
$(oque).animate({
left: '-' + $('.clientesHome ul li').width() + 'px'
}, regressivo ,
'linear',
function (){
//
$('.clientesHome ul li:first').clone().appendTo('.clientesHome ul');
$('.clientesHome ul li:first').remove();
$(oque).css('left','0');
animar(oque);
});
}
}