In response to this question about jQuery effects, I thought about using the callback
argument to .fadeIn( 500, my_function )
.
While in principle, this is a viable idea, I have no clue (and neither has the jQuery documentation :( ) if the callback is allowed to recurse:
function keep_animating(){
$("#id").fadeIn(500).fadeOut(500, keep_animating );
}
You could add a debugger breakpoint and test if the stack size increases or not. :)
However, since animations/fadings use setTimeout/setInterval I highly guess that the call depth does not increase, i.e. it's not prone to stack overflows.
I took the time to ask the 'people who know'... There is no stack-overflow, since there is no explicit recursion: the fadeIn
, fadeOut
... methods all just create an entry on the effects queue. That means that the keep_animating
function is not executed from within the same context.
Courtesy to dave methvin:
What you are describing as "recursion" is not actually recursion. jQuery's visual effects run on a setTimeout timer, so the callback function isn't run immediately as it would be in recursion. Instead, the callback runs after the animation completes in several "steps", each triggered by a setTimeout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With