diff options
Diffstat (limited to 'lib/dojo/fx')
-rw-r--r-- | lib/dojo/fx/Toggler.js | 104 | ||||
-rw-r--r-- | lib/dojo/fx/Toggler.js.uncompressed.js | 103 | ||||
-rw-r--r-- | lib/dojo/fx/easing.js | 284 | ||||
-rw-r--r-- | lib/dojo/fx/easing.js.uncompressed.js | 284 |
4 files changed, 391 insertions, 384 deletions
diff --git a/lib/dojo/fx/Toggler.js b/lib/dojo/fx/Toggler.js index dc4693d8e..265586c37 100644 --- a/lib/dojo/fx/Toggler.js +++ b/lib/dojo/fx/Toggler.js @@ -4,105 +4,5 @@ see: http://dojotoolkit.org/license for details */ - -if(!dojo._hasResource["dojo.fx.Toggler"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojo.fx.Toggler"] = true; -dojo.provide("dojo.fx.Toggler"); - - -dojo.declare("dojo.fx.Toggler", null, { - // summary: - // A simple `dojo.Animation` toggler API. - // - // description: - // class constructor for an animation toggler. It accepts a packed - // set of arguments about what type of animation to use in each - // direction, duration, etc. All available members are mixed into - // these animations from the constructor (for example, `node`, - // `showDuration`, `hideDuration`). - // - // example: - // | var t = new dojo.fx.Toggler({ - // | node: "nodeId", - // | showDuration: 500, - // | // hideDuration will default to "200" - // | showFunc: dojo.fx.wipeIn, - // | // hideFunc will default to "fadeOut" - // | }); - // | t.show(100); // delay showing for 100ms - // | // ...time passes... - // | t.hide(); - - // node: DomNode - // the node to target for the showing and hiding animations - node: null, - - // showFunc: Function - // The function that returns the `dojo.Animation` to show the node - showFunc: dojo.fadeIn, - - // hideFunc: Function - // The function that returns the `dojo.Animation` to hide the node - hideFunc: dojo.fadeOut, - - // showDuration: - // Time in milliseconds to run the show Animation - showDuration: 200, - - // hideDuration: - // Time in milliseconds to run the hide Animation - hideDuration: 200, - - // FIXME: need a policy for where the toggler should "be" the next - // time show/hide are called if we're stopped somewhere in the - // middle. - // FIXME: also would be nice to specify individual showArgs/hideArgs mixed into - // each animation individually. - // FIXME: also would be nice to have events from the animations exposed/bridged - - /*===== - _showArgs: null, - _showAnim: null, - - _hideArgs: null, - _hideAnim: null, - - _isShowing: false, - _isHiding: false, - =====*/ - - constructor: function(args){ - var _t = this; - - dojo.mixin(_t, args); - _t.node = args.node; - _t._showArgs = dojo.mixin({}, args); - _t._showArgs.node = _t.node; - _t._showArgs.duration = _t.showDuration; - _t.showAnim = _t.showFunc(_t._showArgs); - - _t._hideArgs = dojo.mixin({}, args); - _t._hideArgs.node = _t.node; - _t._hideArgs.duration = _t.hideDuration; - _t.hideAnim = _t.hideFunc(_t._hideArgs); - - dojo.connect(_t.showAnim, "beforeBegin", dojo.hitch(_t.hideAnim, "stop", true)); - dojo.connect(_t.hideAnim, "beforeBegin", dojo.hitch(_t.showAnim, "stop", true)); - }, - - show: function(delay){ - // summary: Toggle the node to showing - // delay: Integer? - // Ammount of time to stall playing the show animation - return this.showAnim.play(delay || 0); - }, - - hide: function(delay){ - // summary: Toggle the node to hidden - // delay: Integer? - // Ammount of time to stall playing the hide animation - return this.hideAnim.play(delay || 0); - } -}); - -} +//>>built +define("dojo/fx/Toggler",["../_base/lang","../_base/declare","../_base/fx","../_base/connect"],function(_1,_2,_3,_4){return _2("dojo.fx.Toggler",null,{node:null,showFunc:_3.fadeIn,hideFunc:_3.fadeOut,showDuration:200,hideDuration:200,constructor:function(_5){var _6=this;_1.mixin(_6,_5);_6.node=_5.node;_6._showArgs=_1.mixin({},_5);_6._showArgs.node=_6.node;_6._showArgs.duration=_6.showDuration;_6.showAnim=_6.showFunc(_6._showArgs);_6._hideArgs=_1.mixin({},_5);_6._hideArgs.node=_6.node;_6._hideArgs.duration=_6.hideDuration;_6.hideAnim=_6.hideFunc(_6._hideArgs);_4.connect(_6.showAnim,"beforeBegin",_1.hitch(_6.hideAnim,"stop",true));_4.connect(_6.hideAnim,"beforeBegin",_1.hitch(_6.showAnim,"stop",true));},show:function(_7){return this.showAnim.play(_7||0);},hide:function(_8){return this.hideAnim.play(_8||0);}});});
\ No newline at end of file diff --git a/lib/dojo/fx/Toggler.js.uncompressed.js b/lib/dojo/fx/Toggler.js.uncompressed.js new file mode 100644 index 000000000..3e4891af2 --- /dev/null +++ b/lib/dojo/fx/Toggler.js.uncompressed.js @@ -0,0 +1,103 @@ +define("dojo/fx/Toggler", ["../_base/lang","../_base/declare","../_base/fx", "../_base/connect"], + function(lang, declare, baseFx, connectUtil) { + // module: + // dojo/fx/Toggler + // summary: + // TODOC + +return declare("dojo.fx.Toggler", null, { + // summary: + // A simple `dojo.Animation` toggler API. + // + // description: + // class constructor for an animation toggler. It accepts a packed + // set of arguments about what type of animation to use in each + // direction, duration, etc. All available members are mixed into + // these animations from the constructor (for example, `node`, + // `showDuration`, `hideDuration`). + // + // example: + // | var t = new dojo.fx.Toggler({ + // | node: "nodeId", + // | showDuration: 500, + // | // hideDuration will default to "200" + // | showFunc: dojo.fx.wipeIn, + // | // hideFunc will default to "fadeOut" + // | }); + // | t.show(100); // delay showing for 100ms + // | // ...time passes... + // | t.hide(); + + // node: DomNode + // the node to target for the showing and hiding animations + node: null, + + // showFunc: Function + // The function that returns the `dojo.Animation` to show the node + showFunc: baseFx.fadeIn, + + // hideFunc: Function + // The function that returns the `dojo.Animation` to hide the node + hideFunc: baseFx.fadeOut, + + // showDuration: + // Time in milliseconds to run the show Animation + showDuration: 200, + + // hideDuration: + // Time in milliseconds to run the hide Animation + hideDuration: 200, + + // FIXME: need a policy for where the toggler should "be" the next + // time show/hide are called if we're stopped somewhere in the + // middle. + // FIXME: also would be nice to specify individual showArgs/hideArgs mixed into + // each animation individually. + // FIXME: also would be nice to have events from the animations exposed/bridged + + /*===== + _showArgs: null, + _showAnim: null, + + _hideArgs: null, + _hideAnim: null, + + _isShowing: false, + _isHiding: false, + =====*/ + + constructor: function(args){ + var _t = this; + + lang.mixin(_t, args); + _t.node = args.node; + _t._showArgs = lang.mixin({}, args); + _t._showArgs.node = _t.node; + _t._showArgs.duration = _t.showDuration; + _t.showAnim = _t.showFunc(_t._showArgs); + + _t._hideArgs = lang.mixin({}, args); + _t._hideArgs.node = _t.node; + _t._hideArgs.duration = _t.hideDuration; + _t.hideAnim = _t.hideFunc(_t._hideArgs); + + connectUtil.connect(_t.showAnim, "beforeBegin", lang.hitch(_t.hideAnim, "stop", true)); + connectUtil.connect(_t.hideAnim, "beforeBegin", lang.hitch(_t.showAnim, "stop", true)); + }, + + show: function(delay){ + // summary: Toggle the node to showing + // delay: Integer? + // Ammount of time to stall playing the show animation + return this.showAnim.play(delay || 0); + }, + + hide: function(delay){ + // summary: Toggle the node to hidden + // delay: Integer? + // Ammount of time to stall playing the hide animation + return this.hideAnim.play(delay || 0); + } +}); + +}); diff --git a/lib/dojo/fx/easing.js b/lib/dojo/fx/easing.js index c26af8971..e9a2fb75b 100644 --- a/lib/dojo/fx/easing.js +++ b/lib/dojo/fx/easing.js @@ -4,285 +4,5 @@ see: http://dojotoolkit.org/license for details */ - -if(!dojo._hasResource["dojo.fx.easing"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojo.fx.easing"] = true; -dojo.provide("dojo.fx.easing"); - -dojo.getObject("fx.easing", true, dojo); - -dojo.fx.easing = { - // summary: - // Collection of easing functions to use beyond the default - // `dojo._defaultEasing` function. - // - // description: - // - // Easing functions are used to manipulate the iteration through - // an `dojo.Animation`s _Line. _Line being the properties of an Animation, - // and the easing function progresses through that Line determing - // how quickly (or slowly) it should go. Or more accurately: modify - // the value of the _Line based on the percentage of animation completed. - // - // All functions follow a simple naming convention of "ease type" + "when". - // If the name of the function ends in Out, the easing described appears - // towards the end of the animation. "In" means during the beginning, - // and InOut means both ranges of the Animation will applied, both - // beginning and end. - // - // One does not call the easing function directly, it must be passed to - // the `easing` property of an animation. - // - // example: - // | dojo.require("dojo.fx.easing"); - // | var anim = dojo.fadeOut({ - // | node: 'node', - // | duration: 2000, - // | // note there is no () - // | easing: dojo.fx.easing.quadIn - // | }).play(); - // - - linear: function(/* Decimal? */n){ - // summary: A linear easing function - return n; - }, - - quadIn: function(/* Decimal? */n){ - return Math.pow(n, 2); - }, - - quadOut: function(/* Decimal? */n){ - return n * (n - 2) * -1; - }, - - quadInOut: function(/* Decimal? */n){ - n = n * 2; - if(n < 1){ return Math.pow(n, 2) / 2; } - return -1 * ((--n) * (n - 2) - 1) / 2; - }, - - cubicIn: function(/* Decimal? */n){ - return Math.pow(n, 3); - }, - - cubicOut: function(/* Decimal? */n){ - return Math.pow(n - 1, 3) + 1; - }, - - cubicInOut: function(/* Decimal? */n){ - n = n * 2; - if(n < 1){ return Math.pow(n, 3) / 2; } - n -= 2; - return (Math.pow(n, 3) + 2) / 2; - }, - - quartIn: function(/* Decimal? */n){ - return Math.pow(n, 4); - }, - - quartOut: function(/* Decimal? */n){ - return -1 * (Math.pow(n - 1, 4) - 1); - }, - - quartInOut: function(/* Decimal? */n){ - n = n * 2; - if(n < 1){ return Math.pow(n, 4) / 2; } - n -= 2; - return -1 / 2 * (Math.pow(n, 4) - 2); - }, - - quintIn: function(/* Decimal? */n){ - return Math.pow(n, 5); - }, - - quintOut: function(/* Decimal? */n){ - return Math.pow(n - 1, 5) + 1; - }, - - quintInOut: function(/* Decimal? */n){ - n = n * 2; - if(n < 1){ return Math.pow(n, 5) / 2; }; - n -= 2; - return (Math.pow(n, 5) + 2) / 2; - }, - - sineIn: function(/* Decimal? */n){ - return -1 * Math.cos(n * (Math.PI / 2)) + 1; - }, - - sineOut: function(/* Decimal? */n){ - return Math.sin(n * (Math.PI / 2)); - }, - - sineInOut: function(/* Decimal? */n){ - return -1 * (Math.cos(Math.PI * n) - 1) / 2; - }, - - expoIn: function(/* Decimal? */n){ - return (n == 0) ? 0 : Math.pow(2, 10 * (n - 1)); - }, - - expoOut: function(/* Decimal? */n){ - return (n == 1) ? 1 : (-1 * Math.pow(2, -10 * n) + 1); - }, - - expoInOut: function(/* Decimal? */n){ - if(n == 0){ return 0; } - if(n == 1){ return 1; } - n = n * 2; - if(n < 1){ return Math.pow(2, 10 * (n - 1)) / 2; } - --n; - return (-1 * Math.pow(2, -10 * n) + 2) / 2; - }, - - circIn: function(/* Decimal? */n){ - return -1 * (Math.sqrt(1 - Math.pow(n, 2)) - 1); - }, - - circOut: function(/* Decimal? */n){ - n = n - 1; - return Math.sqrt(1 - Math.pow(n, 2)); - }, - - circInOut: function(/* Decimal? */n){ - n = n * 2; - if(n < 1){ return -1 / 2 * (Math.sqrt(1 - Math.pow(n, 2)) - 1); } - n -= 2; - return 1 / 2 * (Math.sqrt(1 - Math.pow(n, 2)) + 1); - }, - - backIn: function(/* Decimal? */n){ - // summary: - // An easing function that starts away from the target, - // and quickly accelerates towards the end value. - // - // Use caution when the easing will cause values to become - // negative as some properties cannot be set to negative values. - var s = 1.70158; - return Math.pow(n, 2) * ((s + 1) * n - s); - }, - - backOut: function(/* Decimal? */n){ - // summary: - // An easing function that pops past the range briefly, and slowly comes back. - // - // description: - // An easing function that pops past the range briefly, and slowly comes back. - // - // Use caution when the easing will cause values to become negative as some - // properties cannot be set to negative values. - - n = n - 1; - var s = 1.70158; - return Math.pow(n, 2) * ((s + 1) * n + s) + 1; - }, - - backInOut: function(/* Decimal? */n){ - // summary: - // An easing function combining the effects of `backIn` and `backOut` - // - // description: - // An easing function combining the effects of `backIn` and `backOut`. - // Use caution when the easing will cause values to become negative - // as some properties cannot be set to negative values. - var s = 1.70158 * 1.525; - n = n * 2; - if(n < 1){ return (Math.pow(n, 2) * ((s + 1) * n - s)) / 2; } - n-=2; - return (Math.pow(n, 2) * ((s + 1) * n + s) + 2) / 2; - }, - - elasticIn: function(/* Decimal? */n){ - // summary: - // An easing function the elastically snaps from the start value - // - // description: - // An easing function the elastically snaps from the start value - // - // Use caution when the elasticity will cause values to become negative - // as some properties cannot be set to negative values. - if(n == 0 || n == 1){ return n; } - var p = .3; - var s = p / 4; - n = n - 1; - return -1 * Math.pow(2, 10 * n) * Math.sin((n - s) * (2 * Math.PI) / p); - }, - - elasticOut: function(/* Decimal? */n){ - // summary: - // An easing function that elasticly snaps around the target value, - // near the end of the Animation - // - // description: - // An easing function that elasticly snaps around the target value, - // near the end of the Animation - // - // Use caution when the elasticity will cause values to become - // negative as some properties cannot be set to negative values. - if(n==0 || n == 1){ return n; } - var p = .3; - var s = p / 4; - return Math.pow(2, -10 * n) * Math.sin((n - s) * (2 * Math.PI) / p) + 1; - }, - - elasticInOut: function(/* Decimal? */n){ - // summary: - // An easing function that elasticly snaps around the value, near - // the beginning and end of the Animation. - // - // description: - // An easing function that elasticly snaps around the value, near - // the beginning and end of the Animation. - // - // Use caution when the elasticity will cause values to become - // negative as some properties cannot be set to negative values. - if(n == 0) return 0; - n = n * 2; - if(n == 2) return 1; - var p = .3 * 1.5; - var s = p / 4; - if(n < 1){ - n -= 1; - return -.5 * (Math.pow(2, 10 * n) * Math.sin((n - s) * (2 * Math.PI) / p)); - } - n -= 1; - return .5 * (Math.pow(2, -10 * n) * Math.sin((n - s) * (2 * Math.PI) / p)) + 1; - }, - - bounceIn: function(/* Decimal? */n){ - // summary: - // An easing function that 'bounces' near the beginning of an Animation - return (1 - dojo.fx.easing.bounceOut(1 - n)); // Decimal - }, - - bounceOut: function(/* Decimal? */n){ - // summary: - // An easing function that 'bounces' near the end of an Animation - var s = 7.5625; - var p = 2.75; - var l; - if(n < (1 / p)){ - l = s * Math.pow(n, 2); - }else if(n < (2 / p)){ - n -= (1.5 / p); - l = s * Math.pow(n, 2) + .75; - }else if(n < (2.5 / p)){ - n -= (2.25 / p); - l = s * Math.pow(n, 2) + .9375; - }else{ - n -= (2.625 / p); - l = s * Math.pow(n, 2) + .984375; - } - return l; - }, - - bounceInOut: function(/* Decimal? */n){ - // summary: - // An easing function that 'bounces' at the beginning and end of the Animation - if(n < 0.5){ return dojo.fx.easing.bounceIn(n * 2) / 2; } - return (dojo.fx.easing.bounceOut(n * 2 - 1) / 2) + 0.5; // Decimal - } -}; - -} +//>>built +define("dojo/fx/easing",["../_base/lang"],function(_1){var _2={linear:function(n){return n;},quadIn:function(n){return Math.pow(n,2);},quadOut:function(n){return n*(n-2)*-1;},quadInOut:function(n){n=n*2;if(n<1){return Math.pow(n,2)/2;}return -1*((--n)*(n-2)-1)/2;},cubicIn:function(n){return Math.pow(n,3);},cubicOut:function(n){return Math.pow(n-1,3)+1;},cubicInOut:function(n){n=n*2;if(n<1){return Math.pow(n,3)/2;}n-=2;return (Math.pow(n,3)+2)/2;},quartIn:function(n){return Math.pow(n,4);},quartOut:function(n){return -1*(Math.pow(n-1,4)-1);},quartInOut:function(n){n=n*2;if(n<1){return Math.pow(n,4)/2;}n-=2;return -1/2*(Math.pow(n,4)-2);},quintIn:function(n){return Math.pow(n,5);},quintOut:function(n){return Math.pow(n-1,5)+1;},quintInOut:function(n){n=n*2;if(n<1){return Math.pow(n,5)/2;}n-=2;return (Math.pow(n,5)+2)/2;},sineIn:function(n){return -1*Math.cos(n*(Math.PI/2))+1;},sineOut:function(n){return Math.sin(n*(Math.PI/2));},sineInOut:function(n){return -1*(Math.cos(Math.PI*n)-1)/2;},expoIn:function(n){return (n==0)?0:Math.pow(2,10*(n-1));},expoOut:function(n){return (n==1)?1:(-1*Math.pow(2,-10*n)+1);},expoInOut:function(n){if(n==0){return 0;}if(n==1){return 1;}n=n*2;if(n<1){return Math.pow(2,10*(n-1))/2;}--n;return (-1*Math.pow(2,-10*n)+2)/2;},circIn:function(n){return -1*(Math.sqrt(1-Math.pow(n,2))-1);},circOut:function(n){n=n-1;return Math.sqrt(1-Math.pow(n,2));},circInOut:function(n){n=n*2;if(n<1){return -1/2*(Math.sqrt(1-Math.pow(n,2))-1);}n-=2;return 1/2*(Math.sqrt(1-Math.pow(n,2))+1);},backIn:function(n){var s=1.70158;return Math.pow(n,2)*((s+1)*n-s);},backOut:function(n){n=n-1;var s=1.70158;return Math.pow(n,2)*((s+1)*n+s)+1;},backInOut:function(n){var s=1.70158*1.525;n=n*2;if(n<1){return (Math.pow(n,2)*((s+1)*n-s))/2;}n-=2;return (Math.pow(n,2)*((s+1)*n+s)+2)/2;},elasticIn:function(n){if(n==0||n==1){return n;}var p=0.3;var s=p/4;n=n-1;return -1*Math.pow(2,10*n)*Math.sin((n-s)*(2*Math.PI)/p);},elasticOut:function(n){if(n==0||n==1){return n;}var p=0.3;var s=p/4;return Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/p)+1;},elasticInOut:function(n){if(n==0){return 0;}n=n*2;if(n==2){return 1;}var p=0.3*1.5;var s=p/4;if(n<1){n-=1;return -0.5*(Math.pow(2,10*n)*Math.sin((n-s)*(2*Math.PI)/p));}n-=1;return 0.5*(Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/p))+1;},bounceIn:function(n){return (1-_2.bounceOut(1-n));},bounceOut:function(n){var s=7.5625;var p=2.75;var l;if(n<(1/p)){l=s*Math.pow(n,2);}else{if(n<(2/p)){n-=(1.5/p);l=s*Math.pow(n,2)+0.75;}else{if(n<(2.5/p)){n-=(2.25/p);l=s*Math.pow(n,2)+0.9375;}else{n-=(2.625/p);l=s*Math.pow(n,2)+0.984375;}}}return l;},bounceInOut:function(n){if(n<0.5){return _2.bounceIn(n*2)/2;}return (_2.bounceOut(n*2-1)/2)+0.5;}};_1.setObject("dojo.fx.easing",_2);return _2;});
\ No newline at end of file diff --git a/lib/dojo/fx/easing.js.uncompressed.js b/lib/dojo/fx/easing.js.uncompressed.js new file mode 100644 index 000000000..6663deb2b --- /dev/null +++ b/lib/dojo/fx/easing.js.uncompressed.js @@ -0,0 +1,284 @@ +define("dojo/fx/easing", ["../_base/lang"], function(lang) { +// module: +// dojo/fx/easing +// summary: +// This module defines standard easing functions that are useful for animations. + +var easingFuncs = /*===== dojo.fx.easing= =====*/ { + // summary: + // Collection of easing functions to use beyond the default + // `dojo._defaultEasing` function. + // + // description: + // + // Easing functions are used to manipulate the iteration through + // an `dojo.Animation`s _Line. _Line being the properties of an Animation, + // and the easing function progresses through that Line determing + // how quickly (or slowly) it should go. Or more accurately: modify + // the value of the _Line based on the percentage of animation completed. + // + // All functions follow a simple naming convention of "ease type" + "when". + // If the name of the function ends in Out, the easing described appears + // towards the end of the animation. "In" means during the beginning, + // and InOut means both ranges of the Animation will applied, both + // beginning and end. + // + // One does not call the easing function directly, it must be passed to + // the `easing` property of an animation. + // + // example: + // | dojo.require("dojo.fx.easing"); + // | var anim = dojo.fadeOut({ + // | node: 'node', + // | duration: 2000, + // | // note there is no () + // | easing: dojo.fx.easing.quadIn + // | }).play(); + // + + linear: function(/* Decimal? */n){ + // summary: A linear easing function + return n; + }, + + quadIn: function(/* Decimal? */n){ + return Math.pow(n, 2); + }, + + quadOut: function(/* Decimal? */n){ + return n * (n - 2) * -1; + }, + + quadInOut: function(/* Decimal? */n){ + n = n * 2; + if(n < 1){ return Math.pow(n, 2) / 2; } + return -1 * ((--n) * (n - 2) - 1) / 2; + }, + + cubicIn: function(/* Decimal? */n){ + return Math.pow(n, 3); + }, + + cubicOut: function(/* Decimal? */n){ + return Math.pow(n - 1, 3) + 1; + }, + + cubicInOut: function(/* Decimal? */n){ + n = n * 2; + if(n < 1){ return Math.pow(n, 3) / 2; } + n -= 2; + return (Math.pow(n, 3) + 2) / 2; + }, + + quartIn: function(/* Decimal? */n){ + return Math.pow(n, 4); + }, + + quartOut: function(/* Decimal? */n){ + return -1 * (Math.pow(n - 1, 4) - 1); + }, + + quartInOut: function(/* Decimal? */n){ + n = n * 2; + if(n < 1){ return Math.pow(n, 4) / 2; } + n -= 2; + return -1 / 2 * (Math.pow(n, 4) - 2); + }, + + quintIn: function(/* Decimal? */n){ + return Math.pow(n, 5); + }, + + quintOut: function(/* Decimal? */n){ + return Math.pow(n - 1, 5) + 1; + }, + + quintInOut: function(/* Decimal? */n){ + n = n * 2; + if(n < 1){ return Math.pow(n, 5) / 2; } + n -= 2; + return (Math.pow(n, 5) + 2) / 2; + }, + + sineIn: function(/* Decimal? */n){ + return -1 * Math.cos(n * (Math.PI / 2)) + 1; + }, + + sineOut: function(/* Decimal? */n){ + return Math.sin(n * (Math.PI / 2)); + }, + + sineInOut: function(/* Decimal? */n){ + return -1 * (Math.cos(Math.PI * n) - 1) / 2; + }, + + expoIn: function(/* Decimal? */n){ + return (n == 0) ? 0 : Math.pow(2, 10 * (n - 1)); + }, + + expoOut: function(/* Decimal? */n){ + return (n == 1) ? 1 : (-1 * Math.pow(2, -10 * n) + 1); + }, + + expoInOut: function(/* Decimal? */n){ + if(n == 0){ return 0; } + if(n == 1){ return 1; } + n = n * 2; + if(n < 1){ return Math.pow(2, 10 * (n - 1)) / 2; } + --n; + return (-1 * Math.pow(2, -10 * n) + 2) / 2; + }, + + circIn: function(/* Decimal? */n){ + return -1 * (Math.sqrt(1 - Math.pow(n, 2)) - 1); + }, + + circOut: function(/* Decimal? */n){ + n = n - 1; + return Math.sqrt(1 - Math.pow(n, 2)); + }, + + circInOut: function(/* Decimal? */n){ + n = n * 2; + if(n < 1){ return -1 / 2 * (Math.sqrt(1 - Math.pow(n, 2)) - 1); } + n -= 2; + return 1 / 2 * (Math.sqrt(1 - Math.pow(n, 2)) + 1); + }, + + backIn: function(/* Decimal? */n){ + // summary: + // An easing function that starts away from the target, + // and quickly accelerates towards the end value. + // + // Use caution when the easing will cause values to become + // negative as some properties cannot be set to negative values. + var s = 1.70158; + return Math.pow(n, 2) * ((s + 1) * n - s); + }, + + backOut: function(/* Decimal? */n){ + // summary: + // An easing function that pops past the range briefly, and slowly comes back. + // + // description: + // An easing function that pops past the range briefly, and slowly comes back. + // + // Use caution when the easing will cause values to become negative as some + // properties cannot be set to negative values. + + n = n - 1; + var s = 1.70158; + return Math.pow(n, 2) * ((s + 1) * n + s) + 1; + }, + + backInOut: function(/* Decimal? */n){ + // summary: + // An easing function combining the effects of `backIn` and `backOut` + // + // description: + // An easing function combining the effects of `backIn` and `backOut`. + // Use caution when the easing will cause values to become negative + // as some properties cannot be set to negative values. + var s = 1.70158 * 1.525; + n = n * 2; + if(n < 1){ return (Math.pow(n, 2) * ((s + 1) * n - s)) / 2; } + n-=2; + return (Math.pow(n, 2) * ((s + 1) * n + s) + 2) / 2; + }, + + elasticIn: function(/* Decimal? */n){ + // summary: + // An easing function the elastically snaps from the start value + // + // description: + // An easing function the elastically snaps from the start value + // + // Use caution when the elasticity will cause values to become negative + // as some properties cannot be set to negative values. + if(n == 0 || n == 1){ return n; } + var p = .3; + var s = p / 4; + n = n - 1; + return -1 * Math.pow(2, 10 * n) * Math.sin((n - s) * (2 * Math.PI) / p); + }, + + elasticOut: function(/* Decimal? */n){ + // summary: + // An easing function that elasticly snaps around the target value, + // near the end of the Animation + // + // description: + // An easing function that elasticly snaps around the target value, + // near the end of the Animation + // + // Use caution when the elasticity will cause values to become + // negative as some properties cannot be set to negative values. + if(n==0 || n == 1){ return n; } + var p = .3; + var s = p / 4; + return Math.pow(2, -10 * n) * Math.sin((n - s) * (2 * Math.PI) / p) + 1; + }, + + elasticInOut: function(/* Decimal? */n){ + // summary: + // An easing function that elasticly snaps around the value, near + // the beginning and end of the Animation. + // + // description: + // An easing function that elasticly snaps around the value, near + // the beginning and end of the Animation. + // + // Use caution when the elasticity will cause values to become + // negative as some properties cannot be set to negative values. + if(n == 0) return 0; + n = n * 2; + if(n == 2) return 1; + var p = .3 * 1.5; + var s = p / 4; + if(n < 1){ + n -= 1; + return -.5 * (Math.pow(2, 10 * n) * Math.sin((n - s) * (2 * Math.PI) / p)); + } + n -= 1; + return .5 * (Math.pow(2, -10 * n) * Math.sin((n - s) * (2 * Math.PI) / p)) + 1; + }, + + bounceIn: function(/* Decimal? */n){ + // summary: + // An easing function that 'bounces' near the beginning of an Animation + return (1 - easingFuncs.bounceOut(1 - n)); // Decimal + }, + + bounceOut: function(/* Decimal? */n){ + // summary: + // An easing function that 'bounces' near the end of an Animation + var s = 7.5625; + var p = 2.75; + var l; + if(n < (1 / p)){ + l = s * Math.pow(n, 2); + }else if(n < (2 / p)){ + n -= (1.5 / p); + l = s * Math.pow(n, 2) + .75; + }else if(n < (2.5 / p)){ + n -= (2.25 / p); + l = s * Math.pow(n, 2) + .9375; + }else{ + n -= (2.625 / p); + l = s * Math.pow(n, 2) + .984375; + } + return l; + }, + + bounceInOut: function(/* Decimal? */n){ + // summary: + // An easing function that 'bounces' at the beginning and end of the Animation + if(n < 0.5){ return easingFuncs.bounceIn(n * 2) / 2; } + return (easingFuncs.bounceOut(n * 2 - 1) / 2) + 0.5; // Decimal + } +}; + +lang.setObject("dojo.fx.easing", easingFuncs); + +return easingFuncs; +}); |