Coupla things:
1) Nathan wrote:
tween.start('opacity', 0.5, 1).chain(function(){
>
function(){
>
stoerer.setStyle('display', '');
>
}.delay(1000);
>
});
>
And he's correct, except this will generate a syntax error, as you can't
reference an anonymous function's methods without wrapping it in ():
tween.start('opacity', 0.5, 1).chain(function(){
(function(){
stoerer.setStyle('display', '');
}).delay(1000);
});
Didn't want to nit-pick, but if you tried his code you would get errors, and
this little bit of information isn't obvious.
2) whenever you do myFunction.delay, it's the same as calling myFunction(),
only it will wait for the delay duration. So this:
new Fx.Tween(el).start('opacity', 0).chain(myFunction.delay());
Will return a timeout (as Nathan pointed out) to chain, but will execute
your function at run time + the delay. It would be the same as:
new Fx.Tween(el).start('opacity', 0).chain(myFunction());
Instead of
new Fx.Tween(el).start('opacity', 0).chain(myFunction); //note the missing
()
3) Chain.Wait - the script I directed to you, simply does this:
Chain.implement({
wait: function(duration){
return this.chain(function(){
this.callChain.delay($pick(duration, 500), this);
}.bind(this));
}
});
So now:
new Fx.Tween(el).start('opacity', 0).wait(1000).chain(myFunction);
The wait method adds a new function to the chain stack that waits the
specified delay and then calls the next method on the chain stack.
-aaron
On Tue, Oct 14, 2008 at 6:39 AM, nwhite <
[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:
> I think the problem is your not actually passing a function to chain. Your
> anonymous function is valid, however when using delay it returns a
> javascript timeout id. Not a function.
>
> I believe the correct syntax would be:
>
> tween.start('opacity', 0.5, 1).chain(function(){
> function(){
> stoerer.setStyle('display', '');
> }.delay(1000);
> });
>
> I would try and avoid such code as the readability of your code is reduced.
> If you only have a single instance that's probably ok. If you have multiple
> you might end up refactoring in the following manner. (using a class
> structure).
>
> tween.start('opacity', 0.5,
> 1).chain(this.endDelayEffect.bind(this,this.stoerer));
>
> //method in classs
> endDelayEffect : function(element){
> this.restoreDefault.delay(1000,this,[element,'display']);
> }
>
> // method in class
> restoreDefault : function(el,prop){
> $(el).setStyle(prop','');
> }
>
> Now the code end chain effect can easily be recycled for any element or
> effect.
>
>
>
> On Tue, Oct 14, 2008 at 3:44 AM, eskimoblood <[EMAIL
> PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332553&i=0>
> > wrote:
>
>>
>> Thanks, but what's wrong with my solution. I thought I can chain every
>> function and delay() will return a function. So what's the problem?
>>
>> On 13 Okt., 18:21, nutron <[EMAIL
>> PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332553&i=1>>
>> wrote:
>> > http://clientside.cnet.com/docs/Class.Extras/Chain.Wait
>> >
>> > On Mon, Oct 13, 2008 at 6:35 AM, eskimoblood <
>> > [EMAIL
>> > PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332553&i=2>
>> <[EMAIL
>> PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332553&i=3>
>> >
>> >
>> >
>> >
>> > > wrote:
>> >
>> > > To: ''. Its the best way when you set it to 'none' before and you
>> > > don't know if it's block, inline or inline-block in the css, cause it
>> > > will use the rule of the css style. This works very well and has
>> > > nothing to do with the error.
>> >
>> > > On 13 Okt., 14:39, "Iván N Paz" <[EMAIL PROTECTED]<
>> http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1328787&i=0>>
>> > > wrote:
>> > > > ???
>> >
>> > > > >> stoerer.setStyle('display', '')
>> >
>> > > > You are setting the 'display' property, to what???
>> >
>> > > ------------------------------
>> > > View message @
>> > >http://n2.nabble.com/Delay-in-chains-tp1325073p1328787.html
>> > > To start a new topic under MooTools Users, email
>> > > [EMAIL
>> > > PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332553&i=4>
>> <[EMAIL
>> PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332553&i=5>
>> >
>> > > To unsubscribe from MooTools Users, click here< (link removed) >.
>> >
>> > -----
>> > The MooTools Tutorial: http://www.mootorial.comwww.mootorial.com
>> > CNET Clientside: http://clientside.cnet.comclientside.cnet.com
>> > --
>> > View this message in context:
>> http://n2.nabble.com/Delay-in-chains-tp1325073p1329389.html
>> > Sent from the MooTools Users mailing list archive at Nabble.com.
>>
>
>
>
> ------------------------------
> View message @
> http://n2.nabble.com/Delay-in-chains-tp1325073p1332553.html
> To start a new topic under MooTools Users, email
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>
-----
The MooTools Tutorial: http://www.mootorial.com www.mootorial.com
CNET Clientside: http://clientside.cnet.com clientside.cnet.com
--
View this message in context:
http://n2.nabble.com/Delay-in-chains-tp1325073p1333053.html
Sent from the MooTools Users mailing list archive at Nabble.com.