jquery.easing.1.3.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /**
  2. *
  3. * @authors Your Name (you@example.org)
  4. * @date 2014-08-31 16:29:04
  5. * @version $Id$
  6. */
  7. /*
  8. * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
  9. *
  10. * Uses the built in easing capabilities added In jQuery 1.1
  11. * to offer multiple easing options
  12. *
  13. * TERMS OF USE - jQuery Easing
  14. *
  15. * Open source under the BSD License.
  16. *
  17. * Copyright © 2008 George McGinley Smith
  18. * All rights reserved.
  19. *
  20. * Redistribution and use in source and binary forms, with or without modification,
  21. * are permitted provided that the following conditions are met:
  22. *
  23. * Redistributions of source code must retain the above copyright notice, this list of
  24. * conditions and the following disclaimer.
  25. * Redistributions in binary form must reproduce the above copyright notice, this list
  26. * of conditions and the following disclaimer in the documentation and/or other materials
  27. * provided with the distribution.
  28. *
  29. * Neither the name of the author nor the names of contributors may be used to endorse
  30. * or promote products derived from this software without specific prior written permission.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  33. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  34. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  35. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  36. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  37. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  38. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  39. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  40. * OF THE POSSIBILITY OF SUCH DAMAGE.
  41. *
  42. */
  43. // t: current time, b: begInnIng value, c: change In value, d: duration
  44. jQuery.easing['jswing'] = jQuery.easing['swing'];
  45. jQuery.extend( jQuery.easing,
  46. {
  47. def: 'easeOutQuad',
  48. swing: function (x, t, b, c, d) {
  49. //alert(jQuery.easing.default);
  50. return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
  51. },
  52. easeInQuad: function (x, t, b, c, d) {
  53. return c*(t/=d)*t + b;
  54. },
  55. easeOutQuad: function (x, t, b, c, d) {
  56. return -c *(t/=d)*(t-2) + b;
  57. },
  58. easeInOutQuad: function (x, t, b, c, d) {
  59. if ((t/=d/2) < 1) return c/2*t*t + b;
  60. return -c/2 * ((--t)*(t-2) - 1) + b;
  61. },
  62. easeInCubic: function (x, t, b, c, d) {
  63. return c*(t/=d)*t*t + b;
  64. },
  65. easeOutCubic: function (x, t, b, c, d) {
  66. return c*((t=t/d-1)*t*t + 1) + b;
  67. },
  68. easeInOutCubic: function (x, t, b, c, d) {
  69. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  70. return c/2*((t-=2)*t*t + 2) + b;
  71. },
  72. easeInQuart: function (x, t, b, c, d) {
  73. return c*(t/=d)*t*t*t + b;
  74. },
  75. easeOutQuart: function (x, t, b, c, d) {
  76. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  77. },
  78. easeInOutQuart: function (x, t, b, c, d) {
  79. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  80. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  81. },
  82. easeInQuint: function (x, t, b, c, d) {
  83. return c*(t/=d)*t*t*t*t + b;
  84. },
  85. easeOutQuint: function (x, t, b, c, d) {
  86. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  87. },
  88. easeInOutQuint: function (x, t, b, c, d) {
  89. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  90. return c/2*((t-=2)*t*t*t*t + 2) + b;
  91. },
  92. easeInSine: function (x, t, b, c, d) {
  93. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  94. },
  95. easeOutSine: function (x, t, b, c, d) {
  96. return c * Math.sin(t/d * (Math.PI/2)) + b;
  97. },
  98. easeInOutSine: function (x, t, b, c, d) {
  99. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  100. },
  101. easeInExpo: function (x, t, b, c, d) {
  102. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  103. },
  104. easeOutExpo: function (x, t, b, c, d) {
  105. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  106. },
  107. easeInOutExpo: function (x, t, b, c, d) {
  108. if (t==0) return b;
  109. if (t==d) return b+c;
  110. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  111. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  112. },
  113. easeInCirc: function (x, t, b, c, d) {
  114. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  115. },
  116. easeOutCirc: function (x, t, b, c, d) {
  117. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  118. },
  119. easeInOutCirc: function (x, t, b, c, d) {
  120. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  121. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  122. },
  123. easeInElastic: function (x, t, b, c, d) {
  124. var s=1.70158;var p=0;var a=c;
  125. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  126. if (a < Math.abs(c)) { a=c; var s=p/4; }
  127. else var s = p/(2*Math.PI) * Math.asin (c/a);
  128. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  129. },
  130. easeOutElastic: function (x, t, b, c, d) {
  131. var s=1.70158;var p=0;var a=c;
  132. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  133. if (a < Math.abs(c)) { a=c; var s=p/4; }
  134. else var s = p/(2*Math.PI) * Math.asin (c/a);
  135. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  136. },
  137. easeInOutElastic: function (x, t, b, c, d) {
  138. var s=1.70158;var p=0;var a=c;
  139. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  140. if (a < Math.abs(c)) { a=c; var s=p/4; }
  141. else var s = p/(2*Math.PI) * Math.asin (c/a);
  142. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  143. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  144. },
  145. easeInBack: function (x, t, b, c, d, s) {
  146. if (s == undefined) s = 1.70158;
  147. return c*(t/=d)*t*((s+1)*t - s) + b;
  148. },
  149. easeOutBack: function (x, t, b, c, d, s) {
  150. if (s == undefined) s = 1.70158;
  151. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  152. },
  153. easeInOutBack: function (x, t, b, c, d, s) {
  154. if (s == undefined) s = 1.70158;
  155. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  156. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  157. },
  158. easeInBounce: function (x, t, b, c, d) {
  159. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  160. },
  161. easeOutBounce: function (x, t, b, c, d) {
  162. if ((t/=d) < (1/2.75)) {
  163. return c*(7.5625*t*t) + b;
  164. } else if (t < (2/2.75)) {
  165. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  166. } else if (t < (2.5/2.75)) {
  167. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  168. } else {
  169. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  170. }
  171. },
  172. easeInOutBounce: function (x, t, b, c, d) {
  173. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  174. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  175. }
  176. });
  177. /*
  178. *
  179. * TERMS OF USE - EASING EQUATIONS
  180. *
  181. * Open source under the BSD License.
  182. *
  183. * Copyright © 2001 Robert Penner
  184. * All rights reserved.
  185. *
  186. * Redistribution and use in source and binary forms, with or without modification,
  187. * are permitted provided that the following conditions are met:
  188. *
  189. * Redistributions of source code must retain the above copyright notice, this list of
  190. * conditions and the following disclaimer.
  191. * Redistributions in binary form must reproduce the above copyright notice, this list
  192. * of conditions and the following disclaimer in the documentation and/or other materials
  193. * provided with the distribution.
  194. *
  195. * Neither the name of the author nor the names of contributors may be used to endorse
  196. * or promote products derived from this software without specific prior written permission.
  197. *
  198. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  199. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  200. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  201. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  202. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  203. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  204. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  205. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  206. * OF THE POSSIBILITY OF SUCH DAMAGE.
  207. *
  208. */