I've been meaning to write an article on extending the transitions.  Basically 
you can add whatever transitions you want to the Fx.Transitions.  Check out 
lines 3903 to 3947 of mootools-core-1.2.4.js

On Oct 5, 2010, at 9:18 AM, Vittorio wrote:

> What about Fx.Transitions.Quad.easeIn together with
> Fx.Transitions.Bounce.easeOut?
> 
> I googled a lot but couldn't find anything about the topic of setting
> more than one transition to an effect (for example one for the easeIn
> and a different one for the easeOut).
> 
> So I tried to inspect the source code (MooTools 1.2.5) to get a grasp
> of what a Transition really was.
> I came out first with this:
> [code]
> var myFx = new Fx.Morph(myObject, {
>       transition: new Fx.Transition(function(p,x){
>               return (Fx.Transitions.Back.easeOut(p,x) +
> Fx.Transitions.Bounce.easeIn(p,x))/2;
>       }) //it works!
> });
> [/code]
> 
> and then with this:
> [code]
> Fx.Transitions.Combine = function() { //pass in one or more
> FX.Transitions functions
>       var transitions = arguments, n = arguments.length; //establish a
> closure
>       return new Fx.Transition(function(p, x){
>               var i, sum = 0;
>               for (i = 0; i < n; i +=1) {
>                       sum += transitions[i](p, x);
>               }
>               return (sum / n );
>       })
> };
> 
> var myFx = new Fx.Morph(myObject, {
>       transition: Fx.Transitions.Combine(Fx.Transitions.Back.easeOut,
>                                                                       
> Fx.Transitions.Bounce.easeIn,
>                                                                       
> Fx.Transitions.Elastic.easeInOut)
> }); //ugly but works
> [/code]
> 
> which to my great wonder worked as expected :-)
> I make a new Transition that returns a normalized sum of other
> transitions.
> Obviously there are some problems: no error control, the sum effect is
> quite bad on the endings of the effect.
> I could rewrite the Combine to accept only two Transitions, one for
> the first half of the effect and the other for the second half. I
> wrote it in variable parameters form most for completeness and
> exercise.
> 
> My questions are:
> 
> am I reinventing the wheel? is there yet another method of doing so?
> 
> is the structure of Fx.Transitions.Combine correct and uniform with
> the rest of mootools?
> 
> should I add a check for the existance of the parameters? what should
> I do if one is null/missing/not a function/not a Transition?
> 
> if everything is fine how should I publish it?
> 
> I know it could seem of little use, but somehow while studying Fx this
> was a bit that I really though was missing :-)
> 
> Thank you for your comments
> 

Reply via email to