[jQuery] Re: Help refactoring code for css sprite animation

2008-09-22 Thread Michael Geary
That's great, I'm glad it worked! Just a minor point of terminology: There's actually no recursion in that code, although it does have a recursive "feel" to it. The callback functions are called at a later time after the original function has returned. Recursion would be when you have a function

[jQuery] Re: Help refactoring code for css sprite animation

2008-09-22 Thread gogojuice
Thanks Michael Your code worked right off the copy and paste. I knew there was a recursive procedure in there somewhere, but I'm just getting up to speed with Javascript after years of ignoring it due to the pain and suffering involved in writing cross platform stuff. Jquery has made me want

[jQuery] Re: Help refactoring code for css sprite animation

2008-09-21 Thread Michael Geary
Just to explain that code a bit... You can't use a simple for loop, because your repeated steps have to be run asynchronously, when the fadeOut callback function is called. So, instead of using a separate callback function for each step, this code uses a common callback for all the steps, and mak

[jQuery] Re: Help refactoring code for css sprite animation

2008-09-21 Thread Michael Geary
I think you could do it something like this (untested): $.fn.walk = function( now, incr, last ) { var $it = this; step(); function step() { $it.css({ backgroundPosition: now + ' 0' }).show(); now += incr; if( now != last ) $it.fadeOu