<?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: More than one way to skin a jQuery</title>
	<atom:link href="http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/</link>
	<description>jc-designs blog</description>
	<lastBuildDate>Fri, 04 May 2012 13:50:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Erika</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-15237</link>
		<dc:creator>Erika</dc:creator>
		<pubDate>Sat, 10 Dec 2011 14:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-15237</guid>
		<description>Hi,

Is there anyway to make this fading effect loop? I want the fade effect to happen until the user has left the page. Also, my first item in the list is fading in and out twice before the function moves on to the next item. Any help would be greatly appreciated.

Thanks!

Erika</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Is there anyway to make this fading effect loop? I want the fade effect to happen until the user has left the page. Also, my first item in the list is fading in and out twice before the function moves on to the next item. Any help would be greatly appreciated.</p>
<p>Thanks!</p>
<p>Erika</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Common Problems with jQuery .delay()</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-887</link>
		<dc:creator>Common Problems with jQuery .delay()</dc:creator>
		<pubDate>Mon, 02 Aug 2010 20:27:36 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-887</guid>
		<description>[...] be interested in seeing a working example of a Sequential fade-in effect. If you are, head over to The Web Machine and view Jeremy Carlson&#8217;s solution.  Subscribe via [...]</description>
		<content:encoded><![CDATA[<p>[...] be interested in seeing a working example of a Sequential fade-in effect. If you are, head over to The Web Machine and view Jeremy Carlson&#8217;s solution.  Subscribe via [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery Sequential animations revisited&#8230;real world example &#124; jc-designs.net</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-632</link>
		<dc:creator>jQuery Sequential animations revisited&#8230;real world example &#124; jc-designs.net</dc:creator>
		<pubDate>Wed, 23 Jun 2010 04:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-632</guid>
		<description>[...] it be cool if I animated it a little? In fact, why not do something that I did a few posts ago (can view post here), and move each cog left while fading in. Whatever I come up with for the design, won&#8217;t look [...]</description>
		<content:encoded><![CDATA[<p>[...] it be cool if I animated it a little? In fact, why not do something that I did a few posts ago (can view post here), and move each cog left while fading in. Whatever I come up with for the design, won&#8217;t look [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Common Problems with jQuery .delay()</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-619</link>
		<dc:creator>Common Problems with jQuery .delay()</dc:creator>
		<pubDate>Fri, 18 Jun 2010 03:45:40 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-619</guid>
		<description>[...] be interested in seeing a working example of a Sequential fade-in effect. If you are, head over to The Web Machine and view Jeremy Carlson&#039;s solution.   Filed under: JavaScript/jQuery Leave a comment     Comments [...]</description>
		<content:encoded><![CDATA[<p>[...] be interested in seeing a working example of a Sequential fade-in effect. If you are, head over to The Web Machine and view Jeremy Carlson&#39;s solution.   Filed under: JavaScript/jQuery Leave a comment     Comments [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jcDesigns</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-597</link>
		<dc:creator>jcDesigns</dc:creator>
		<pubDate>Tue, 15 Jun 2010 02:16:52 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-597</guid>
		<description>In short....yes. Mine works because it is NOT a loop. Mine goes through the function, at the end of the function, do the function again, but this time &#039;i&#039; is incremented. So I&#039;m not looping, I&#039;m just calling the function over and over, until I&#039;m through the array of elements (divs in my case). You are saying. Do this to each, which does it all at the same time. But you wrote in the code to get around that.</description>
		<content:encoded><![CDATA[<p>In short&#8230;.yes. Mine works because it is NOT a loop. Mine goes through the function, at the end of the function, do the function again, but this time &#8216;i&#8217; is incremented. So I&#8217;m not looping, I&#8217;m just calling the function over and over, until I&#8217;m through the array of elements (divs in my case). You are saying. Do this to each, which does it all at the same time. But you wrote in the code to get around that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph McCullough</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-596</link>
		<dc:creator>Joseph McCullough</dc:creator>
		<pubDate>Mon, 14 Jun 2010 22:15:41 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-596</guid>
		<description>Well Geez, I just made a comment that could have been a blog post itself! lol</description>
		<content:encoded><![CDATA[<p>Well Geez, I just made a comment that could have been a blog post itself! lol</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph McCullough</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-595</link>
		<dc:creator>Joseph McCullough</dc:creator>
		<pubDate>Mon, 14 Jun 2010 22:15:25 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-595</guid>
		<description>I think I&#039;ve figured it out: Callback functions put delay times in relation to one another because the callback function does not occur until the script has finished. That sounds like a &quot;no duh&quot;, but hear me out.

For example:
Let&#039;s say we have 

var wrapper = $(&quot;#wrapper&quot;)

And we want to fade in each element of the wrapper one after another. 

This LOOKS like it would work

for (var i=0; i&lt;$(wrapper).length; i++)
{
$(wrapper[i]).delay(1000).fadeTo(500, 1)
}

It looks like that this code will make each successive element appear after 1000ms. But that&#039;s not how javascript works. This code makes everything come up at once. Why? The delay is in terms of the time of script execution. JavaScript executes these scripts lightning fast: It can execute that entire for loop in a tenth of a second. Consequently, JavaScript sees it like this

wait one second and fade in element at index 0
wait one second and fade in element at index 1
wait one second and fade in element at index 2

Which means that the animations are going to happen at the same time, because the for loop was executed so fast.

Since we obviously can&#039;t (or shouldn&#039;t) slow down how fast JavaScript executes code, there are 2 ways to accommodate this fundamental of JavaScript, and this is where our examples differ. 

My way) Have the delay time multiplied by an incremental amount so it increases every loop.

JavaScript will see it this way

wait 1000ms and fade in element at index 0
wait (1000*2)ms and fade in element at index 1
wait (1000*3)ms and fade in element at index 2

Assuming you wanted to wait one second in between each animation.

This looks like

for (var i=0; i&lt;$(wrapper).length; i++)
{
    $(wrapper[i]).delay(i*1000).fadeTo(500, 1);
}

 However, to have an initial delay, you would have to place in an offsetting value. This offset value has to be applied to every single subsequent execution, otherwise the intervals between the animations won&#039;t be even.

That looks like

for (var i=0; i&lt;$(wrapper).length; i++)
{
    $(wrapper[i]).delay(i*1000+3000).fadeTo(500, 1);
}

That means that the animations will come in one second after each other with an initial 3 second delay. 

Now here is your way, which is MUCH better. This goes along the lines of what we were talking about: If I don&#039;t know the methods to get the job done, I can break it down into math concepts.

Your Way)

It seems that javaScript adds callback functions to a queue, while statements in a for loop are executed immediately. My for loop gave the impression of a delay, but in fact all statements generated by the for loop were executed at just about the same time.

But the callback function will not execute until its caller function is completely finished. So while my forloop statements were executed at just about the same time, JavaScript holds off on callback function execution until the calling function is complete. This way, you can use a set a CONSTANT value for delay, because javaScript does not even execute that code until after a period of time. 


Hope that makes sense!</description>
		<content:encoded><![CDATA[<p>I think I&#8217;ve figured it out: Callback functions put delay times in relation to one another because the callback function does not occur until the script has finished. That sounds like a &#8220;no duh&#8221;, but hear me out.</p>
<p>For example:<br />
Let&#8217;s say we have </p>
<p>var wrapper = $(&#8220;#wrapper&#8221;)</p>
<p>And we want to fade in each element of the wrapper one after another. </p>
<p>This LOOKS like it would work</p>
<p>for (var i=0; i&lt;$(wrapper).length; i++)<br />
{<br />
$(wrapper[i]).delay(1000).fadeTo(500, 1)<br />
}</p>
<p>It looks like that this code will make each successive element appear after 1000ms. But that&#039;s not how javascript works. This code makes everything come up at once. Why? The delay is in terms of the time of script execution. JavaScript executes these scripts lightning fast: It can execute that entire for loop in a tenth of a second. Consequently, JavaScript sees it like this</p>
<p>wait one second and fade in element at index 0<br />
wait one second and fade in element at index 1<br />
wait one second and fade in element at index 2</p>
<p>Which means that the animations are going to happen at the same time, because the for loop was executed so fast.</p>
<p>Since we obviously can&#039;t (or shouldn&#039;t) slow down how fast JavaScript executes code, there are 2 ways to accommodate this fundamental of JavaScript, and this is where our examples differ. </p>
<p>My way) Have the delay time multiplied by an incremental amount so it increases every loop.</p>
<p>JavaScript will see it this way</p>
<p>wait 1000ms and fade in element at index 0<br />
wait (1000*2)ms and fade in element at index 1<br />
wait (1000*3)ms and fade in element at index 2</p>
<p>Assuming you wanted to wait one second in between each animation.</p>
<p>This looks like</p>
<p>for (var i=0; i&lt;$(wrapper).length; i++)<br />
{<br />
    $(wrapper[i]).delay(i*1000).fadeTo(500, 1);<br />
}</p>
<p> However, to have an initial delay, you would have to place in an offsetting value. This offset value has to be applied to every single subsequent execution, otherwise the intervals between the animations won&#039;t be even.</p>
<p>That looks like</p>
<p>for (var i=0; i&lt;$(wrapper).length; i++)<br />
{<br />
    $(wrapper[i]).delay(i*1000+3000).fadeTo(500, 1);<br />
}</p>
<p>That means that the animations will come in one second after each other with an initial 3 second delay. </p>
<p>Now here is your way, which is MUCH better. This goes along the lines of what we were talking about: If I don&#039;t know the methods to get the job done, I can break it down into math concepts.</p>
<p>Your Way)</p>
<p>It seems that javaScript adds callback functions to a queue, while statements in a for loop are executed immediately. My for loop gave the impression of a delay, but in fact all statements generated by the for loop were executed at just about the same time.</p>
<p>But the callback function will not execute until its caller function is completely finished. So while my forloop statements were executed at just about the same time, JavaScript holds off on callback function execution until the calling function is complete. This way, you can use a set a CONSTANT value for delay, because javaScript does not even execute that code until after a period of time. </p>
<p>Hope that makes sense!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jcDesigns</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-594</link>
		<dc:creator>jcDesigns</dc:creator>
		<pubDate>Mon, 14 Jun 2010 19:11:06 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-594</guid>
		<description>Ok, you have used words here that make me feel stupid, but I think what you want to use is the queue() method. So you would have the fadeIn, add the queue() with a function in it calling the delay, then dequeue() method directly after. The queue method will add non-effect methods into the chain, and adding dequeue() will allow the animation or chain to continue where it left off.

So for example, you would have fadeIn(&#039;slow&#039;).queue(function() {$(whatever).delay(&#039;2000&#039;).dequeue();}).fadeOut(&#039;slow&#039;);</description>
		<content:encoded><![CDATA[<p>Ok, you have used words here that make me feel stupid, but I think what you want to use is the queue() method. So you would have the fadeIn, add the queue() with a function in it calling the delay, then dequeue() method directly after. The queue method will add non-effect methods into the chain, and adding dequeue() will allow the animation or chain to continue where it left off.</p>
<p>So for example, you would have fadeIn(&#8216;slow&#8217;).queue(function() {$(whatever).delay(&#8217;2000&#8242;).dequeue();}).fadeOut(&#8216;slow&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph McCullough</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-589</link>
		<dc:creator>Joseph McCullough</dc:creator>
		<pubDate>Sat, 12 Jun 2010 14:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-589</guid>
		<description>Yup! Makes sense. However, I&#039;m kind of confused on something. 

Whenever I was dealing with looping and delays, I could not get delays to be treated as relative to one another, but only in absolutes in terms of when javascript executes the code.

So putting delays in a for loop or recursive function caused everything to show up at once, just because javascript executes the code so fast. That&#039;s why in my loop I had to multiply eveything by i.</description>
		<content:encoded><![CDATA[<p>Yup! Makes sense. However, I&#8217;m kind of confused on something. </p>
<p>Whenever I was dealing with looping and delays, I could not get delays to be treated as relative to one another, but only in absolutes in terms of when javascript executes the code.</p>
<p>So putting delays in a for loop or recursive function caused everything to show up at once, just because javascript executes the code so fast. That&#8217;s why in my loop I had to multiply eveything by i.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jcDesigns</title>
		<link>http://jc-designs.net/blog/2010/06/more-than-one-way-to-skin-a-jquery/comment-page-1/#comment-587</link>
		<dc:creator>jcDesigns</dc:creator>
		<pubDate>Sat, 12 Jun 2010 03:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://jc-designs.net/blog/?p=341#comment-587</guid>
		<description>The arguments.callee is a callback equal to the function itself. If you take that out of the code, it will only show the first div, since it only runs through the function once. After the fadeIn occurs on the first div, the arguments.callee pretty much says run through the function again.

Without the counter, the whole damn thing will show everytime (meaning ALL the children div at once). The i = 0 you obviously know sets the counter at 0. The faders variable is basically returning an array of whatever matched my selection. In this case all the children of the container div. So I basically have an array of [div, div, div]. The first time the function runs through, it does the whole fading thing on the index of 0 (first div), hits the arguments.callee, which says run the damn thing again, this time &#039;i&#039; gets incremented to 1 (2nd div) and the process repeats until it gets through the array.

Whew....thank you for actually making me explain that, it solidified what I was thinking. Does that make sense now?</description>
		<content:encoded><![CDATA[<p>The arguments.callee is a callback equal to the function itself. If you take that out of the code, it will only show the first div, since it only runs through the function once. After the fadeIn occurs on the first div, the arguments.callee pretty much says run through the function again.</p>
<p>Without the counter, the whole damn thing will show everytime (meaning ALL the children div at once). The i = 0 you obviously know sets the counter at 0. The faders variable is basically returning an array of whatever matched my selection. In this case all the children of the container div. So I basically have an array of [div, div, div]. The first time the function runs through, it does the whole fading thing on the index of 0 (first div), hits the arguments.callee, which says run the damn thing again, this time &#8216;i&#8217; gets incremented to 1 (2nd div) and the process repeats until it gets through the array.</p>
<p>Whew&#8230;.thank you for actually making me explain that, it solidified what I was thinking. Does that make sense now?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

