| 1 |
jQuery.easing['jswing'] = jQuery.easing['swing']; |
| 2 |
|
| 3 |
jQuery.extend( jQuery.easing, |
| 4 |
{ |
| 5 |
def: 'easeOutQuad', |
| 6 |
swing: function (x, t, b, c, d) { |
| 7 |
//alert(jQuery.easing.default); |
| 8 |
return jQuery.easing[jQuery.easing.def](x, t, b, c, d); |
| 9 |
}, |
| 10 |
easeInQuad: function (x, t, b, c, d) { |
| 11 |
return c*(t/=d)*t + b; |
| 12 |
}, |
| 13 |
easeOutQuad: function (x, t, b, c, d) { |
| 14 |
return -c *(t/=d)*(t-2) + b; |
| 15 |
}, |
| 16 |
easeInOutQuad: function (x, t, b, c, d) { |
| 17 |
if ((t/=d/2) < 1) return c/2*t*t + b; |
| 18 |
return -c/2 * ((--t)*(t-2) - 1) + b; |
| 19 |
}, |
| 20 |
easeInCubic: function (x, t, b, c, d) { |
| 21 |
return c*(t/=d)*t*t + b; |
| 22 |
}, |
| 23 |
easeOutCubic: function (x, t, b, c, d) { |
| 24 |
return c*((t=t/d-1)*t*t + 1) + b; |
| 25 |
}, |
| 26 |
easeInOutCubic: function (x, t, b, c, d) { |
| 27 |
if ((t/=d/2) < 1) return c/2*t*t*t + b; |
| 28 |
return c/2*((t-=2)*t*t + 2) + b; |
| 29 |
}, |
| 30 |
easeInQuart: function (x, t, b, c, d) { |
| 31 |
return c*(t/=d)*t*t*t + b; |
| 32 |
}, |
| 33 |
easeOutQuart: function (x, t, b, c, d) { |
| 34 |
return -c * ((t=t/d-1)*t*t*t - 1) + b; |
| 35 |
}, |
| 36 |
easeInOutQuart: function (x, t, b, c, d) { |
| 37 |
if ((t/=d/2) < 1) return c/2*t*t*t*t + b; |
| 38 |
return -c/2 * ((t-=2)*t*t*t - 2) + b; |
| 39 |
}, |
| 40 |
easeInQuint: function (x, t, b, c, d) { |
| 41 |
return c*(t/=d)*t*t*t*t + b; |
| 42 |
}, |
| 43 |
easeOutQuint: function (x, t, b, c, d) { |
| 44 |
return c*((t=t/d-1)*t*t*t*t + 1) + b; |
| 45 |
}, |
| 46 |
easeInOutQuint: function (x, t, b, c, d) { |
| 47 |
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; |
| 48 |
return c/2*((t-=2)*t*t*t*t + 2) + b; |
| 49 |
}, |
| 50 |
easeInSine: function (x, t, b, c, d) { |
| 51 |
return -c * Math.cos(t/d * (Math.PI/2)) + c + b; |
| 52 |
}, |
| 53 |
easeOutSine: function (x, t, b, c, d) { |
| 54 |
return c * Math.sin(t/d * (Math.PI/2)) + b; |
| 55 |
}, |
| 56 |
easeInOutSine: function (x, t, b, c, d) { |
| 57 |
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; |
| 58 |
}, |
| 59 |
easeInExpo: function (x, t, b, c, d) { |
| 60 |
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; |
| 61 |
}, |
| 62 |
easeOutExpo: function (x, t, b, c, d) { |
| 63 |
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; |
| 64 |
}, |
| 65 |
easeInOutExpo: function (x, t, b, c, d) { |
| 66 |
if (t==0) return b; |
| 67 |
if (t==d) return b+c; |
| 68 |
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; |
| 69 |
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; |
| 70 |
}, |
| 71 |
easeInCirc: function (x, t, b, c, d) { |
| 72 |
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; |
| 73 |
}, |
| 74 |
easeOutCirc: function (x, t, b, c, d) { |
| 75 |
return c * Math.sqrt(1 - (t=t/d-1)*t) + b; |
| 76 |
}, |
| 77 |
easeInOutCirc: function (x, t, b, c, d) { |
| 78 |
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; |
| 79 |
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; |
| 80 |
}, |
| 81 |
easeInElastic: function (x, t, b, c, d) { |
| 82 |
var s=1.70158;var p=0;var a=c; |
| 83 |
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
| 84 |
if (a < Math.abs(c)) { a=c; var s=p/4; } |
| 85 |
else var s = p/(2*Math.PI) * Math.asin (c/a); |
| 86 |
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
| 87 |
}, |
| 88 |
easeOutElastic: function (x, t, b, c, d) { |
| 89 |
var s=1.70158;var p=0;var a=c; |
| 90 |
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
| 91 |
if (a < Math.abs(c)) { a=c; var s=p/4; } |
| 92 |
else var s = p/(2*Math.PI) * Math.asin (c/a); |
| 93 |
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; |
| 94 |
}, |
| 95 |
easeInOutElastic: function (x, t, b, c, d) { |
| 96 |
var s=1.70158;var p=0;var a=c; |
| 97 |
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); |
| 98 |
if (a < Math.abs(c)) { a=c; var s=p/4; } |
| 99 |
else var s = p/(2*Math.PI) * Math.asin (c/a); |
| 100 |
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
| 101 |
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; |
| 102 |
}, |
| 103 |
easeInBack: function (x, t, b, c, d, s) { |
| 104 |
if (s == undefined) s = 1.70158; |
| 105 |
return c*(t/=d)*t*((s+1)*t - s) + b; |
| 106 |
}, |
| 107 |
easeOutBack: function (x, t, b, c, d, s) { |
| 108 |
if (s == undefined) s = 1.70158; |
| 109 |
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; |
| 110 |
}, |
| 111 |
easeInOutBack: function (x, t, b, c, d, s) { |
| 112 |
if (s == undefined) s = 1.70158; |
| 113 |
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; |
| 114 |
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; |
| 115 |
}, |
| 116 |
easeInBounce: function (x, t, b, c, d) { |
| 117 |
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; |
| 118 |
}, |
| 119 |
easeOutBounce: function (x, t, b, c, d) { |
| 120 |
if ((t/=d) < (1/2.75)) { |
| 121 |
return c*(7.5625*t*t) + b; |
| 122 |
} else if (t < (2/2.75)) { |
| 123 |
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; |
| 124 |
} else if (t < (2.5/2.75)) { |
| 125 |
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; |
| 126 |
} else { |
| 127 |
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; |
| 128 |
} |
| 129 |
}, |
| 130 |
easeInOutBounce: function (x, t, b, c, d) { |
| 131 |
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; |
| 132 |
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; |
| 133 |
} |
| 134 |
}); |
| 135 |
|
| 136 |
jQuery.extend( jQuery.easing, |
| 137 |
{ |
| 138 |
easeIn: function (x, t, b, c, d) { |
| 139 |
return jQuery.easing.easeInQuad(x, t, b, c, d); |
| 140 |
}, |
| 141 |
easeOut: function (x, t, b, c, d) { |
| 142 |
return jQuery.easing.easeOutQuad(x, t, b, c, d); |
| 143 |
}, |
| 144 |
easeInOut: function (x, t, b, c, d) { |
| 145 |
return jQuery.easing.easeInOutQuad(x, t, b, c, d); |
| 146 |
}, |
| 147 |
expoin: function(x, t, b, c, d) { |
| 148 |
return jQuery.easing.easeInExpo(x, t, b, c, d); |
| 149 |
}, |
| 150 |
expoout: function(x, t, b, c, d) { |
| 151 |
return jQuery.easing.easeOutExpo(x, t, b, c, d); |
| 152 |
}, |
| 153 |
expoinout: function(x, t, b, c, d) { |
| 154 |
return jQuery.easing.easeInOutExpo(x, t, b, c, d); |
| 155 |
}, |
| 156 |
bouncein: function(x, t, b, c, d) { |
| 157 |
return jQuery.easing.easeInBounce(x, t, b, c, d); |
| 158 |
}, |
| 159 |
bounceout: function(x, t, b, c, d) { |
| 160 |
return jQuery.easing.easeOutBounce(x, t, b, c, d); |
| 161 |
}, |
| 162 |
bounceinout: function(x, t, b, c, d) { |
| 163 |
return jQuery.easing.easeInOutBounce(x, t, b, c, d); |
| 164 |
}, |
| 165 |
elasin: function(x, t, b, c, d) { |
| 166 |
return jQuery.easing.easeInElastic(x, t, b, c, d); |
| 167 |
}, |
| 168 |
elasout: function(x, t, b, c, d) { |
| 169 |
return jQuery.easing.easeOutElastic(x, t, b, c, d); |
| 170 |
}, |
| 171 |
elasinout: function(x, t, b, c, d) { |
| 172 |
return jQuery.easing.easeInOutElastic(x, t, b, c, d); |
| 173 |
}, |
| 174 |
backin: function(x, t, b, c, d) { |
| 175 |
return jQuery.easing.easeInBack(x, t, b, c, d); |
| 176 |
}, |
| 177 |
backout: function(x, t, b, c, d) { |
| 178 |
return jQuery.easing.easeOutBack(x, t, b, c, d); |
| 179 |
}, |
| 180 |
backinout: function(x, t, b, c, d) { |
| 181 |
return jQuery.easing.easeInOutBack(x, t, b, c, d); |
| 182 |
} |
| 183 |
}); |