Message from discussion
Ultra-Chaining with jQuery
Received: by 10.150.91.20 with SMTP id o20mr6911038ybb.27.1224783799180;
Thu, 23 Oct 2008 10:43:19 -0700 (PDT)
Return-Path: <jeffkr...@hotmail.com>
Received: from bay0-omc2-s35.bay0.hotmail.com (bay0-omc2-s35.bay0.hotmail.com [65.54.246.171])
by mx.google.com with ESMTP id 39si15819148yxd.2.2008.10.23.10.43.18;
Thu, 23 Oct 2008 10:43:19 -0700 (PDT)
Received-SPF: pass (google.com: domain of jeffkr...@hotmail.com designates 65.54.246.171 as permitted sender) client-ip=65.54.246.171;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of jeffkr...@hotmail.com designates 65.54.246.171 as permitted sender) smtp.mail=jeffkr...@hotmail.com
Received: from hotmail.com ([207.46.9.145]) by bay0-omc2-s35.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959);
Thu, 23 Oct 2008 10:43:18 -0700
Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;
Thu, 23 Oct 2008 10:43:17 -0700
Message-ID: <BAY120-DAV71C57DAABBEC4F6EF69F7B2280@phx.gbl>
Received: from 71.216.203.193 by BAY120-DAV7.phx.gbl with DAV;
Thu, 23 Oct 2008 17:43:15 +0000
X-Originating-IP: [71.216.203.193]
X-Originating-Email: [jeffkr...@hotmail.com]
X-Sender: jeffkr...@hotmail.com
From: "Jeffrey Kretz" <jeffkr...@hotmail.com>
To: <jquery-dev@googlegroups.com>
References: <1645a610-fba2-4d8b-bc1f-92a5e1455736@j68g2000hsf.googlegroups.com> <003c01c9323a$320dffc0$9629ff40$@com> <5f5647a8-df7b-467f-87d8-932171c67a3b@k7g2000hsd.googlegroups.com> <002101c932d3$f2f5c0d0$d8e14270$@com> <8e5da36a-6b26-480f-b291-87b609289239@m3g2000hsc.googlegroups.com> <c8b0b2e7-6452-4636-aac4-dc02c3977961@f63g2000hsf.googlegroups.com>
In-Reply-To: <c8b0b2e7-6452-4636-aac4-dc02c3977961@f63g2000hsf.googlegroups.com>
Subject: RE: [jquery-dev] Re: Ultra-Chaining with jQuery
Date: Thu, 23 Oct 2008 10:42:59 -0700
Message-ID: <001e01c93536$ca7e7100$5f7b5300$@com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: Ack1CLwvgua5mEO0TEeNy0NMEV7SHwAK9M6w
Content-Language: en-us
X-OriginalArrivalTime: 23 Oct 2008 17:43:17.0738 (UTC) FILETIME=[D52704A0:01C93536]
Return-Path: jeffkr...@hotmail.com
I tend to agree. But either way, is a wait() function technically feasible?
I tried hacking my way though it last night, and couldn't figure out the
implementation of code that would pause execution while a setInterval
function did it's work, and only THEN return the "this" jQuery object.
Does anyone know how to solve the technical hurdle here?
I guess you could call it "asynchronous setInterval"
JK
-----Original Message-----
From: jquery-dev@googlegroups.com [mailto:jquery-dev@googlegroups.com] On
Behalf Of Bohdan Ganicky
Sent: Thursday, October 23, 2008 4:07 AM
To: jQuery Development
Subject: [jquery-dev] Re: Ultra-Chaining with jQuery
HI ricardobeat,
I don't think this is a good idea. Most of the time I expect
everything to happen as fast as possible. Waiting is mostly good for
animations only and even that's not always true. At least that's how I
feel it.
--
Bohdan
On Oct 23, 2:43=A0am, ricardobeat <ricardob...@gmail.com> wrote:
> That's exactly what I said the day before, you pratically read my
> mind :]http://ejohn.org/blog/ultra-chaining-with-jquery/#comment-321336
>
> What about making all methods 'wait' by default? That's what most
> people expect anyway, people new to jQuery only find out the
> animations run "in parallel" when they happen to casually chain
> something with it. Then you could pass a 'skip' argument if you wanted
> it to run immediatelly. Wouldn't be backwards compatible, but I wonder
> how many apps would break because of this, haven't seen anyone
> chaining animation methods.
>
> - ricardo
>
> On 20 out, 14:50, "Jeffrey Kretz" <jeffkr...@hotmail.com> wrote:
>
> > It seems that the tricky part is that the hide() function (as in all
> > animation functions) use a setInterval, but return the "this" object
> > immediately.
>
> > Ohhh. =A0I have an idea.
>
> > What if the wait() function set a flag in the object saying this object
is
> > waiting for an animation to finish.
>
> > Then, any subsequent jQuery.fn methods that are called get added to a
queue
> > to be executed after the animation is finished.
>
> > Once the animation is done, the wait flag is turned off and jQuery.fn
> > methods are executed immediately as usual.
>
> > So it would look like this:
>
> > jQuery("div").hide("slow")
> > =A0 .wait()
> > =A0 .addClass("done")
> > =A0 .find("span")
> > =A0 =A0 .addClass("done")
> > =A0 .end()
> > =A0 .show("slow")
> > =A0 .wait()
> > =A0 .removeClass("done")
> > =A0 .find("span")
> > =A0 =A0 .removeClass("done");
>
> > JK
>
> > -----Original Message-----
> > From: jquery-dev@googlegroups.com [mailto:jquery-dev@googlegroups.com]
On
>
> > Behalf Of nikomomo
> > Sent: Monday, October 20, 2008 1:01 AM
> > To: jQuery Development
> > Subject: [jquery-dev] Re: Ultra-Chaining with jQuery
>
> > First, you can do that with the callback parameter.
>
> > jQuery("div").hide("slow")
> > =A0 .wait()
> > =A0 .addClass("done")
> > =A0 .find("span")
> > =A0 =A0 .addClass("done")
> > =A0 .end()
> > =A0 .show("slow", function() {
> > =A0 =A0 $(this).removeClass("done");
> > =A0 })
>
> > But to create a wait() function, I think you have to create a lock/
> > semaphore (a simple counter), incremented in jQuery.anime (or anything
> > that create a timer callback?), decremented at the end of the anime,
> > and tested in the wait() function.
>
> > On 20 oct, 00:29, "Jeffrey Kretz" <jeffkr...@hotmail.com> wrote:
> > > That's an interesting idea -- personally I like this syntax a lot.
>
> > > But because javascript isn't a true multithreading environment, I
wonder
> > if
> > > this would be possible at all.
>
> > > It's not like the wait() function can detect for the existence of an
> > > animation, pause execution until the animation is done, and only then
> > return
> > > the "this" object.
>
> > > Does anyone know if there's a way to create such behavior?
>
> > > JK
>
> > > -----Original Message-----
> > > From: jquery-dev@googlegroups.com [mailto:jquery-dev@googlegroups.com=
]
On
>
> > > Behalf Of xwisdom
> > > Sent: Sunday, October 19, 2008 12:43 PM
> > > To: jQuery Development
> > > Subject: [jquery-dev] RE: Ultra-Chaining with jQuery
>
> > > Sorry Guys but I could not find the thread mentioned on John's
> > > website:http://ejohn.org/blog/ultra-chaining-with-jquery/
>
> > > Anyway, the chaining system looks ok but rather than using a chain()
> > > metod how about using a wait() method that would block or process
> > > succeeding calls after the preceding call has been completed:
>
> > > jQuery("div").hide("slow")
> > > =A0 .wait()
> > > =A0 .addClass("done")
> > > =A0 .find("span")
> > > =A0 =A0 .addClass("done")
> > > =A0 .end()
> > > =A0 .show("slow")
> > > =A0 .wait()
> > > =A0 .removeClass("done")
>
> > > Just my 2cents