I'm writing a little jQuery component that animates in response to button presses and also should go automatically as well. I was just wondering if this function recursive or not, I can't quite work it out.
function animate_next_internal() {
$('#sc_thumbnails').animate(
{ top: '-=106' },
500,
function() {
animate_next_internal();
}
);
}
My actual function is more complicated to allow for stops and starts, this is just a simplified example.
EDIT It could either overflow the stack or not, depending on how the events are handled internally. Possibilities:
animate() directy calls the done callback, in which case an overflow is inevitable.
animate() schedules the callback for calling by some external dispatching mechanism and then terminates, in which case it will never overflow.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…