<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaScript Color Fading Script</title>
	<atom:link href="http://www.leigeber.com/2008/05/javascript-color-fading-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/</link>
	<description>This web development blog features fresh articles on JavaScript, AJAX, CSS, XHTML, PHP, Photoshop and more.</description>
	<lastBuildDate>Fri, 27 Aug 2010 12:26:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Lisa</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-11708</link>
		<dc:creator>Lisa</dc:creator>
		<pubDate>Thu, 26 Aug 2010 14:00:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-11708</guid>
		<description>Very nice colour blend, thanks for the resource. LT</description>
		<content:encoded><![CDATA[<p>Very nice colour blend, thanks for the resource. LT</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-11659</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 17 Aug 2010 02:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-11659</guid>
		<description>Loop fade:

Change 

function animate(id......

to

function animateColor(id,element,steps,er,eg,eb,rint,gint,bint,speed,start,end,steps) {


Add at the end of that same procedure:

	if (target.step == steps) {

		colorFade(id,element,end,start,steps,speed) 

	}</description>
		<content:encoded><![CDATA[<p>Loop fade:</p>
<p>Change </p>
<p>function animate(id&#8230;&#8230;</p>
<p>to</p>
<p>function animateColor(id,element,steps,er,eg,eb,rint,gint,bint,speed,start,end,steps) {</p>
<p>Add at the end of that same procedure:</p>
<p>	if (target.step == steps) {</p>
<p>		colorFade(id,element,end,start,steps,speed) </p>
<p>	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bateria blackbarry</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-11642</link>
		<dc:creator>Bateria blackbarry</dc:creator>
		<pubDate>Mon, 09 Aug 2010 20:40:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-11642</guid>
		<description>Thanks heaps for he script, its really great to see a nice clean transition.</description>
		<content:encoded><![CDATA[<p>Thanks heaps for he script, its really great to see a nice clean transition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javascript 颜色褪色脚本</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-11601</link>
		<dc:creator>Javascript 颜色褪色脚本</dc:creator>
		<pubDate>Tue, 27 Jul 2010 02:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-11601</guid>
		<description>[...] 查看演示和教程 [...]</description>
		<content:encoded><![CDATA[<p>[...] 查看演示和教程 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Exceptional Ajax/javascript Techniques (Recently Created) &#124; amitkosti.name</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-11544</link>
		<dc:creator>Exceptional Ajax/javascript Techniques (Recently Created) &#124; amitkosti.name</dc:creator>
		<pubDate>Sun, 11 Jul 2010 12:36:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-11544</guid>
		<description>[...] it from here.  24) JavaScript Color Fading Script- This lightweight JavaScript allows for easy color transitions. Add fading effects to tables, divs [...]</description>
		<content:encoded><![CDATA[<p>[...] it from here.  24) JavaScript Color Fading Script- This lightweight JavaScript allows for easy color transitions. Add fading effects to tables, divs [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan R</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-10786</link>
		<dc:creator>Ryan R</dc:creator>
		<pubDate>Mon, 11 Jan 2010 23:01:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-10786</guid>
		<description>A few comments...
1. In the colorFade section you&#039;re declaring step twice.

2. Steps and speed as parameters don&#039;t really mean a whole lot. I changed those paramters to duration (in millisecons, not optional) and framesPerSecond (default of 24) so you can specify how smooth the animation is and how long the it should take:
function colorFade(id, element, start, end, duration, framesPerSecond) {
	var steps,speed,startrgb,endrgb,er,eg,eb,step,rint,gint,bint;
	var target = document.getElementByID(id);
	framesPerSecond = framesPerSecond &#124;&#124; 24;
	steps = framesPerSecond * (duration / 1000);
	speed = 1000 / framesPerSecond;
	clearInterval(target.timer);
	...
}

3. Theres a section in the colorFade function where you&#039;re setting color integers, then you check if the value is zero and set to 1 if it is. You could use the Math.max function instead:
rint = Math.max(Math.round(Math.abs(target.r-er) / steps), 1);

4. You should just pass target to the animateColor function instead of id, then you don&#039;t need to get the element in the animateColor function.

5. You&#039;ve got a section in the animateColor function where your checking if the color is &gt;= to the end color and adding or subtracting the increment (and parsing the values [only half the time] when they are already numbers). This could be written as:
var r = target.r;
var g = target.g;
var b = target.b;
r += (rint * (r &gt;= er ? -1 : 1));
g += (gint * (g &gt;= eg ? -1 : 1));
b += (bint * (b &gt;= eb ? -1 : 1));

6. You&#039;ve got 2 sections in the animateColor function where you&#039;re setting the style based of the element. First, you&#039;re declaring the color variable before the conditional, so you should remove both sections and move it to after the conditional. Second, change the whole conditional to just set the style of the element that is passed in:
function animateColor(...) {
	...
	var color;
	if (target.step &lt;= steps) {
		...
		color = &#039;rgb(&#039; + r + &#039;,&#039; + g + &#039;,&#039; + b + &#039;)&#039;;
		...
	} else {
		...
		color = &#039;rgb(&#039; + er + &#039;,&#039; + eg + &#039;,&#039; + eb + &#039;)&#039;;
	}
	target.style[element] = color;
}</description>
		<content:encoded><![CDATA[<p>A few comments&#8230;<br />
1. In the colorFade section you&#39;re declaring step twice.</p>
<p>2. Steps and speed as parameters don&#39;t really mean a whole lot. I changed those paramters to duration (in millisecons, not optional) and framesPerSecond (default of 24) so you can specify how smooth the animation is and how long the it should take:<br />
function colorFade(id, element, start, end, duration, framesPerSecond) {<br />
	var steps,speed,startrgb,endrgb,er,eg,eb,step,rint,gint,bint;<br />
	var target = document.getElementByID(id);<br />
	framesPerSecond = framesPerSecond || 24;<br />
	steps = framesPerSecond * (duration / 1000);<br />
	speed = 1000 / framesPerSecond;<br />
	clearInterval(target.timer);<br />
	&#8230;<br />
}</p>
<p>3. Theres a section in the colorFade function where you&#39;re setting color integers, then you check if the value is zero and set to 1 if it is. You could use the Math.max function instead:<br />
rint = Math.max(Math.round(Math.abs(target.r-er) / steps), 1);</p>
<p>4. You should just pass target to the animateColor function instead of id, then you don&#39;t need to get the element in the animateColor function.</p>
<p>5. You&#39;ve got a section in the animateColor function where your checking if the color is &gt;= to the end color and adding or subtracting the increment (and parsing the values [only half the time] when they are already numbers). This could be written as:<br />
var r = target.r;<br />
var g = target.g;<br />
var b = target.b;<br />
r += (rint * (r &gt;= er ? -1 : 1));<br />
g += (gint * (g &gt;= eg ? -1 : 1));<br />
b += (bint * (b &gt;= eb ? -1 : 1));</p>
<p>6. You&#39;ve got 2 sections in the animateColor function where you&#39;re setting the style based of the element. First, you&#39;re declaring the color variable before the conditional, so you should remove both sections and move it to after the conditional. Second, change the whole conditional to just set the style of the element that is passed in:<br />
function animateColor(&#8230;) {<br />
	&#8230;<br />
	var color;<br />
	if (target.step &lt;= steps) {<br />
		&#8230;<br />
		color = &#39;rgb(&#39; + r + &#39;,&#39; + g + &#39;,&#39; + b + &#39;)&#39;;<br />
		&#8230;<br />
	} else {<br />
		&#8230;<br />
		color = &#39;rgb(&#39; + er + &#39;,&#39; + eg + &#39;,&#39; + eb + &#39;)&#39;;<br />
	}<br />
	target.style[element] = color;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chris</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-10775</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Sat, 09 Jan 2010 21:48:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-10775</guid>
		<description>thanks you very much! :)</description>
		<content:encoded><![CDATA[<p>thanks you very much! <img src='http://www.leigeber.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharebrain JavaScript Color Fading Script &#187;</title>
		<link>http://www.leigeber.com/2008/05/javascript-color-fading-script/comment-page-2/#comment-10767</link>
		<dc:creator>Sharebrain JavaScript Color Fading Script &#187;</dc:creator>
		<pubDate>Fri, 08 Jan 2010 11:23:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.leigeber.com/?p=36#comment-10767</guid>
		<description>[...] looking for another simple effect that can bring something brilliant to your website appearance? Try this lightweight JavaScript Color Fading Script. It gives you color transition that is fading gradually to another color.You can apply this script [...]</description>
		<content:encoded><![CDATA[<p>[...] looking for another simple effect that can bring something brilliant to your website appearance? Try this lightweight JavaScript Color Fading Script. It gives you color transition that is fading gradually to another color.You can apply this script [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
