[thelist] Javascript (Math Skills Needed)

E Michael Brandt michael at divaHTML.com
Wed Aug 8 12:14:39 CDT 2007


It appears you simply call the fader() function with the final values 
you want, so

fader(element,243,244,255)

and of course in place of "element" you use the object you want to fade.

Did you try that?

-- 

E. Michael Brandt

www.divaHTML.com
divaGPS : you-are-here menu highlighting
divaFAQ : FAQ pages with pizazz

www.valleywebdesigns.com
JustSo PictureWindow
JustSo PhotoAlbum

--

Jon Hughes wrote:
> I got this snippet from Jeremy Keith's book, and modified it slightly:
> 
> function fader(element,red,green,blue) {
>   if (element.fade) {
>    clearTimeout(element.fade);
>   }
>   element.style.backgroundColor = "rgb("+red+","+green+","+blue+")";
>   if (red == 255 && green == 255 && blue == 255) {
>    return;
>   }
>   var newred = red + Math.ceil((255 - red)/10);
>   var newgreen = green + Math.ceil((255 - green)/10);
>   var newblue = blue + Math.ceil((255 - blue)/10);
>   var repeat = function() {
>    fader(element,newred,newgreen,newblue)
>   };
>   element.fade = setTimeout(repeat,100);
>  }
> 
> Basically, this will fade the element from your rgb value to white...
> but I don't want it to fade to white, I want it to fade to:
> R: 243, G: 244, B: 255 --- #F3F4FF
> 
> I tried replacing values, but I honestly have no idea what the math is
> doing, so it makes it extremely difficult for me to edit.
> 
> Does anyone know a way to fade any color to the color I want?
> 
> Thanks,
> 
>  - Jon



More information about the thelist mailing list