6 description: Contains a set of advanced transitions to be used with any of the Fx Classes.
8 license: MIT-style license.
11 - Easing Equations by Robert Penner, <http://www.robertpenner.com/easing/>, modified and optimized to be used with MooTools.
15 provides: Fx.Transitions
22 getTransition: function(){
23 var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
24 if (typeof trans == 'string'){
25 var data = trans.split(':');
26 trans = Fx.Transitions;
27 trans = trans[data[0]] || trans[data[0].capitalize()];
28 if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
35 Fx.Transition = function(transition, params){
36 params = Array.from(params);
37 return Object.append(transition, {
38 easeIn: function(pos){
39 return transition(pos, params);
41 easeOut: function(pos){
42 return 1 - transition(1 - pos, params);
44 easeInOut: function(pos){
45 return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2;
50 Fx.Transitions = new Hash({
52 linear: function(zero){
58 Fx.Transitions.extend = function(transitions){
59 for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
62 Fx.Transitions.extend({
65 return Math.pow(p, x[0] || 6);
69 return Math.pow(2, 8 * (p - 1));
73 return 1 - Math.sin(Math.acos(p));
77 return 1 - Math.sin((1 - p) * Math.PI / 2);
82 return Math.pow(p, 2) * ((x + 1) * p - x);
87 for (var a = 0, b = 1; 1; a += b, b /= 2){
88 if (p >= (7 - 4 * a) / 11){
89 value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
96 Elastic: function(p, x){
97 return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);
102 ['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){
103 Fx.Transitions[transition] = new Fx.Transition(function(p){
104 return Math.pow(p, [i + 2]);