Why can't you pass arguments into setTimeout in a self referencing function call?

CaptainCage

New Member
I think there is a better way to do this, and perhaps someone can point out my mistakes.I am pulsing the box-shadow blur css property by counting up and down, having the function call itself once it is initiated. For some reason I can't pass the arguments to the setTimeout call that were passed in the first time.Any ideas on how to more cleanly write this? It works, but it would be nice to even generalize it for animating other css properties.\[code\]var pulseBoxShadowBlurCounter = 0;var pulseBoxShadowBlurDirection;$(document).ready(function() { // dom bindspulseBoxShadowBlur($('#getData-btn'),14,'#fff',100); // start the process});function pulseBoxShadowBlur(pulseElement,max,color,delayTime){var cssInput = '0px 0px '+pulseBoxShadowBlurCounter+'px '+color;$(pulseElement).css('box-shadow', cssInput); if(pulseBoxShadowBlurCounter == max){ pulseBoxShadowBlurDirection = 1; // backwards } if(pulseBoxShadowBlurCounter == -5){ // negative num for pause at 0 time pulseBoxShadowBlurDirection = 0; // forward } if(pulseBoxShadowBlurDirection == 0){ pulseBoxShadowBlurCounter++; }else{ pulseBoxShadowBlurCounter--; }setTimeout( "pulseBoxShadowBlur($('#getData-btn'),14,'#fff',100);",delayTime ); // loop}\[/code\]
 
Back
Top