1. var effect = {
    2. Linear: function (t, b, c, d) {
    3. return c * t / d + b;
    4. },
    5. Bounce: {
    6. easeIn: function (t, b, c, d) {
    7. return c - effect.Bounce.easeOut(d - t, 0, c, d) + b;
    8. },
    9. easeOut: function (t, b, c, d) {
    10. if ((t /= d) < (1 / 2.75)) {
    11. return c * (7.5625 * t * t) + b;
    12. } else if (t < (2 / 2.75)) {
    13. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
    14. } else if (t < (2.5 / 2.75)) {
    15. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
    16. } else {
    17. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
    18. }
    19. },
    20. easeInOut: function (t, b, c, d) {
    21. if (t < d / 2) {
    22. return effect.Bounce.easeIn(t * 2, 0, c, d) * .5 + b;
    23. }
    24. return effect.Bounce.easeOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    25. }
    26. },
    27. Quad: {
    28. easeIn: function (t, b, c, d) {
    29. return c * (t /= d) * t + b;
    30. },
    31. easeOut: function (t, b, c, d) {
    32. return -c * (t /= d) * (t - 2) + b;
    33. },
    34. easeInOut: function (t, b, c, d) {
    35. if ((t /= d / 2) < 1) {
    36. return c / 2 * t * t + b;
    37. }
    38. return -c / 2 * ((--t) * (t - 2) - 1) + b;
    39. }
    40. },
    41. Cubic: {
    42. easeIn: function (t, b, c, d) {
    43. return c * (t /= d) * t * t + b;
    44. },
    45. easeOut: function (t, b, c, d) {
    46. return c * ((t = t / d - 1) * t * t + 1) + b;
    47. },
    48. easeInOut: function (t, b, c, d) {
    49. if ((t /= d / 2) < 1) {
    50. return c / 2 * t * t * t + b;
    51. }
    52. return c / 2 * ((t -= 2) * t * t + 2) + b;
    53. }
    54. },
    55. Quart: {
    56. easeIn: function (t, b, c, d) {
    57. return c * (t /= d) * t * t * t + b;
    58. },
    59. easeOut: function (t, b, c, d) {
    60. return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    61. },
    62. easeInOut: function (t, b, c, d) {
    63. if ((t /= d / 2) < 1) {
    64. return c / 2 * t * t * t * t + b;
    65. }
    66. return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    67. }
    68. },
    69. Quint: {
    70. easeIn: function (t, b, c, d) {
    71. return c * (t /= d) * t * t * t * t + b;
    72. },
    73. easeOut: function (t, b, c, d) {
    74. return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    75. },
    76. easeInOut: function (t, b, c, d) {
    77. if ((t /= d / 2) < 1) {
    78. return c / 2 * t * t * t * t * t + b;
    79. }
    80. return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    81. }
    82. },
    83. Sine: {
    84. easeIn: function (t, b, c, d) {
    85. return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    86. },
    87. easeOut: function (t, b, c, d) {
    88. return c * Math.sin(t / d * (Math.PI / 2)) + b;
    89. },
    90. easeInOut: function (t, b, c, d) {
    91. return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    92. }
    93. },
    94. Expo: {
    95. easeIn: function (t, b, c, d) {
    96. return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    97. },
    98. easeOut: function (t, b, c, d) {
    99. return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    100. },
    101. easeInOut: function (t, b, c, d) {
    102. if (t === 0) return b;
    103. if (t === d) return b + c;
    104. if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
    105. return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    106. }
    107. },
    108. Circ: {
    109. easeIn: function (t, b, c, d) {
    110. return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    111. },
    112. easeOut: function (t, b, c, d) {
    113. return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    114. },
    115. easeInOut: function (t, b, c, d) {
    116. if ((t /= d / 2) < 1) {
    117. return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
    118. }
    119. return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    120. }
    121. },
    122. Back: {
    123. easeIn: function (t, b, c, d, s) {
    124. if (s === undefined) s = 1.70158;
    125. return c * (t /= d) * t * ((s + 1) * t - s) + b;
    126. },
    127. easeOut: function (t, b, c, d, s) {
    128. if (s === undefined) s = 1.70158;
    129. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    130. },
    131. easeInOut: function (t, b, c, d, s) {
    132. if (s === undefined) s = 1.70158;
    133. if ((t /= d / 2) < 1) {
    134. return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
    135. }
    136. return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    137. }
    138. },
    139. Elastic: {
    140. easeIn: function (t, b, c, d, a, p) {
    141. if (t === 0) return b;
    142. if ((t /= d) === 1) return b + c;
    143. if (!p) p = d * .3;
    144. var s;
    145. !a || a < Math.abs(c) ? (a = c, s = p / 4) : s = p / (2 * Math.PI) * Math.asin(c / a);
    146. return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    147. },
    148. easeOut: function (t, b, c, d, a, p) {
    149. if (t === 0) return b;
    150. if ((t /= d) === 1) return b + c;
    151. if (!p) p = d * .3;
    152. var s;
    153. !a || a < Math.abs(c) ? (a = c, s = p / 4) : s = p / (2 * Math.PI) * Math.asin(c / a);
    154. return (a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b);
    155. },
    156. easeInOut: function (t, b, c, d, a, p) {
    157. if (t === 0) return b;
    158. if ((t /= d / 2) === 2) return b + c;
    159. if (!p) p = d * (.3 * 1.5);
    160. var s;
    161. !a || a < Math.abs(c) ? (a = c, s = p / 4) : s = p / (2 * Math.PI) * Math.asin(c / a);
    162. if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    163. return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    164. }
    165. }
    166. };