I have a setInterval
to loop an animation, with a delay between each recursion.
the queue executes the delay first then the function, and so fourth
can it be possible to make the animation starts instantly after the page load, then the delay ?
I'm aware that animate()
has a mandatory queue
parameter, but that triggers inside the plugin (the function inside animate()
) to fire, but not the timer (setInterval
).
this is a sample of an animation
setInterval(function() {
$('div').animate({
marginLeft: '+=150px'
}, 800,
function() {
$(this).animate({
marginLeft: '-=150px'
}, 800)
})
}, 3000)
i don't want to start a new question, but since it's related, i found here in this question, that I can loop using setTimeout
which is better since there's a bug when you change tabs and you switch back, elements get messy
which gives me the idea to control the queue
in this update
except that the delay can't be set no matter how much I change the value
here's the last update after applying the queue
parameter, i expected to work instantly then apply the delay, but the delay can't be set