jquery-easing.js (4869B)
1 /* 2 * jQuery Easing v1.3.2 - http://gsgd.co.uk/sandbox/jquery/easing/ 3 * Open source under the BSD License. 4 * Copyright © 2008 George McGinley Smith 5 * All rights reserved. 6 * https://raw.github.com/gdsmith/jquery-easing/master/LICENSE 7 */ 8 9 // t: current time, b: begInnIng value, c: change In value, d: duration 10 (function($){$.easing['jswing'] = $.easing['swing']; 11 12 $.extend( $.easing, 13 { 14 def: 'easeOutQuad', 15 swing: function (x, t, b, c, d) { 16 //alert($.easing.default); 17 return $.easing[$.easing.def](x, t, b, c, d); 18 }, 19 easeInQuad: function (x, t, b, c, d) { 20 return c*(t/=d)*t + b; 21 }, 22 easeOutQuad: function (x, t, b, c, d) { 23 return -c *(t/=d)*(t-2) + b; 24 }, 25 easeInOutQuad: function (x, t, b, c, d) { 26 if ((t/=d/2) < 1) return c/2*t*t + b; 27 return -c/2 * ((--t)*(t-2) - 1) + b; 28 }, 29 easeInCubic: function (x, t, b, c, d) { 30 return c*(t/=d)*t*t + b; 31 }, 32 easeOutCubic: function (x, t, b, c, d) { 33 return c*((t=t/d-1)*t*t + 1) + b; 34 }, 35 easeInOutCubic: function (x, t, b, c, d) { 36 if ((t/=d/2) < 1) return c/2*t*t*t + b; 37 return c/2*((t-=2)*t*t + 2) + b; 38 }, 39 easeInQuart: function (x, t, b, c, d) { 40 return c*(t/=d)*t*t*t + b; 41 }, 42 easeOutQuart: function (x, t, b, c, d) { 43 return -c * ((t=t/d-1)*t*t*t - 1) + b; 44 }, 45 easeInOutQuart: function (x, t, b, c, d) { 46 if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 47 return -c/2 * ((t-=2)*t*t*t - 2) + b; 48 }, 49 easeInQuint: function (x, t, b, c, d) { 50 return c*(t/=d)*t*t*t*t + b; 51 }, 52 easeOutQuint: function (x, t, b, c, d) { 53 return c*((t=t/d-1)*t*t*t*t + 1) + b; 54 }, 55 easeInOutQuint: function (x, t, b, c, d) { 56 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 57 return c/2*((t-=2)*t*t*t*t + 2) + b; 58 }, 59 easeInSine: function (x, t, b, c, d) { 60 return -c * Math.cos(t/d * (Math.PI/2)) + c + b; 61 }, 62 easeOutSine: function (x, t, b, c, d) { 63 return c * Math.sin(t/d * (Math.PI/2)) + b; 64 }, 65 easeInOutSine: function (x, t, b, c, d) { 66 return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; 67 }, 68 easeInExpo: function (x, t, b, c, d) { 69 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; 70 }, 71 easeOutExpo: function (x, t, b, c, d) { 72 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; 73 }, 74 easeInOutExpo: function (x, t, b, c, d) { 75 if (t==0) return b; 76 if (t==d) return b+c; 77 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; 78 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; 79 }, 80 easeInCirc: function (x, t, b, c, d) { 81 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; 82 }, 83 easeOutCirc: function (x, t, b, c, d) { 84 return c * Math.sqrt(1 - (t=t/d-1)*t) + b; 85 }, 86 easeInOutCirc: function (x, t, b, c, d) { 87 if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; 88 return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; 89 }, 90 easeInElastic: function (x, t, b, c, d) { 91 var s=1.70158;var p=0;var a=c; 92 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 93 if (a < Math.abs(c)) { a=c; var s=p/4; } 94 else var s = p/(2*Math.PI) * Math.asin (c/a); 95 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 96 }, 97 easeOutElastic: function (x, t, b, c, d) { 98 var s=1.70158;var p=0;var a=c; 99 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 100 if (a < Math.abs(c)) { a=c; var s=p/4; } 101 else var s = p/(2*Math.PI) * Math.asin (c/a); 102 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; 103 }, 104 easeInOutElastic: function (x, t, b, c, d) { 105 var s=1.70158;var p=0;var a=c; 106 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); 107 if (a < Math.abs(c)) { a=c; var s=p/4; } 108 else var s = p/(2*Math.PI) * Math.asin (c/a); 109 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 110 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 111 }, 112 easeInBack: function (x, t, b, c, d, s) { 113 if (s == undefined) s = 1.70158; 114 return c*(t/=d)*t*((s+1)*t - s) + b; 115 }, 116 easeOutBack: function (x, t, b, c, d, s) { 117 if (s == undefined) s = 1.70158; 118 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 119 }, 120 easeInOutBack: function (x, t, b, c, d, s) { 121 if (s == undefined) s = 1.70158; 122 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 123 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 124 }, 125 easeInBounce: function (x, t, b, c, d) { 126 return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; 127 }, 128 easeOutBounce: function (x, t, b, c, d) { 129 if ((t/=d) < (1/2.75)) { 130 return c*(7.5625*t*t) + b; 131 } else if (t < (2/2.75)) { 132 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 133 } else if (t < (2.5/2.75)) { 134 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 135 } else { 136 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 137 } 138 }, 139 easeInOutBounce: function (x, t, b, c, d) { 140 if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; 141 return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 142 } 143 });})(jQuery);