25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

169 satır
4.2 KiB

  1. /*
  2. * jQuery Easing v1.4.1 - 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. console.log('THIS IS EASING');
  9. (function (factory) {
  10. if (typeof define === "function" && define.amd) {
  11. define(['jquery'], function ($) {
  12. return factory($);
  13. });
  14. } else if (typeof module === "object" && typeof module.exports === "object") {
  15. exports = factory(require('jquery'));
  16. } else {
  17. factory(jQuery);
  18. }
  19. })(function($){
  20. // Preserve the original jQuery "swing" easing as "jswing"
  21. $.easing.jswing = $.easing.swing;
  22. var pow = Math.pow,
  23. sqrt = Math.sqrt,
  24. sin = Math.sin,
  25. cos = Math.cos,
  26. PI = Math.PI,
  27. c1 = 1.70158,
  28. c2 = c1 * 1.525,
  29. c3 = c1 + 1,
  30. c4 = ( 2 * PI ) / 3,
  31. c5 = ( 2 * PI ) / 4.5;
  32. // x is the fraction of animation progress, in the range 0..1
  33. function bounceOut(x) {
  34. var n1 = 7.5625,
  35. d1 = 2.75;
  36. if ( x < 1/d1 ) {
  37. return n1*x*x;
  38. } else if ( x < 2/d1 ) {
  39. return n1*(x-=(1.5/d1))*x + 0.75;
  40. } else if ( x < 2.5/d1 ) {
  41. return n1*(x-=(2.25/d1))*x + 0.9375;
  42. } else {
  43. return n1*(x-=(2.625/d1))*x + 0.984375;
  44. }
  45. }
  46. $.extend( $.easing,
  47. {
  48. def: 'easeOutQuad',
  49. swing: function (x) {
  50. return $.easing[$.easing.def](x);
  51. },
  52. easeInQuad: function (x) {
  53. return x * x;
  54. },
  55. easeOutQuad: function (x) {
  56. return 1 - ( 1 - x ) * ( 1 - x );
  57. },
  58. easeInOutQuad: function (x) {
  59. return x < 0.5 ?
  60. 2 * x * x :
  61. 1 - pow( -2 * x + 2, 2 ) / 2;
  62. },
  63. easeInCubic: function (x) {
  64. return x * x * x;
  65. },
  66. easeOutCubic: function (x) {
  67. return 1 - pow( 1 - x, 3 );
  68. },
  69. easeInOutCubic: function (x) {
  70. return x < 0.5 ?
  71. 4 * x * x * x :
  72. 1 - pow( -2 * x + 2, 3 ) / 2;
  73. },
  74. easeInQuart: function (x) {
  75. return x * x * x * x;
  76. },
  77. easeOutQuart: function (x) {
  78. return 1 - pow( 1 - x, 4 );
  79. },
  80. easeInOutQuart: function (x) {
  81. return x < 0.5 ?
  82. 8 * x * x * x * x :
  83. 1 - pow( -2 * x + 2, 4 ) / 2;
  84. },
  85. easeInQuint: function (x) {
  86. return x * x * x * x * x;
  87. },
  88. easeOutQuint: function (x) {
  89. return 1 - pow( 1 - x, 5 );
  90. },
  91. easeInOutQuint: function (x) {
  92. return x < 0.5 ?
  93. 16 * x * x * x * x * x :
  94. 1 - pow( -2 * x + 2, 5 ) / 2;
  95. },
  96. easeInSine: function (x) {
  97. return 1 - cos( x * PI/2 );
  98. },
  99. easeOutSine: function (x) {
  100. return sin( x * PI/2 );
  101. },
  102. easeInOutSine: function (x) {
  103. return -( cos( PI * x ) - 1 ) / 2;
  104. },
  105. easeInExpo: function (x) {
  106. return x === 0 ? 0 : pow( 2, 10 * x - 10 );
  107. },
  108. easeOutExpo: function (x) {
  109. return x === 1 ? 1 : 1 - pow( 2, -10 * x );
  110. },
  111. easeInOutExpo: function (x) {
  112. return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
  113. pow( 2, 20 * x - 10 ) / 2 :
  114. ( 2 - pow( 2, -20 * x + 10 ) ) / 2;
  115. },
  116. easeInCirc: function (x) {
  117. return 1 - sqrt( 1 - pow( x, 2 ) );
  118. },
  119. easeOutCirc: function (x) {
  120. return sqrt( 1 - pow( x - 1, 2 ) );
  121. },
  122. easeInOutCirc: function (x) {
  123. return x < 0.5 ?
  124. ( 1 - sqrt( 1 - pow( 2 * x, 2 ) ) ) / 2 :
  125. ( sqrt( 1 - pow( -2 * x + 2, 2 ) ) + 1 ) / 2;
  126. },
  127. easeInElastic: function (x) {
  128. return x === 0 ? 0 : x === 1 ? 1 :
  129. -pow( 2, 10 * x - 10 ) * sin( ( x * 10 - 10.75 ) * c4 );
  130. },
  131. easeOutElastic: function (x) {
  132. return x === 0 ? 0 : x === 1 ? 1 :
  133. pow( 2, -10 * x ) * sin( ( x * 10 - 0.75 ) * c4 ) + 1;
  134. },
  135. easeInOutElastic: function (x) {
  136. return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
  137. -( pow( 2, 20 * x - 10 ) * sin( ( 20 * x - 11.125 ) * c5 )) / 2 :
  138. pow( 2, -20 * x + 10 ) * sin( ( 20 * x - 11.125 ) * c5 ) / 2 + 1;
  139. },
  140. easeInBack: function (x) {
  141. return c3 * x * x * x - c1 * x * x;
  142. },
  143. easeOutBack: function (x) {
  144. return 1 + c3 * pow( x - 1, 3 ) + c1 * pow( x - 1, 2 );
  145. },
  146. easeInOutBack: function (x) {
  147. return x < 0.5 ?
  148. ( pow( 2 * x, 2 ) * ( ( c2 + 1 ) * 2 * x - c2 ) ) / 2 :
  149. ( pow( 2 * x - 2, 2 ) *( ( c2 + 1 ) * ( x * 2 - 2 ) + c2 ) + 2 ) / 2;
  150. },
  151. easeInBounce: function (x) {
  152. return 1 - bounceOut( 1 - x );
  153. },
  154. easeOutBounce: bounceOut,
  155. easeInOutBounce: function (x) {
  156. return x < 0.5 ?
  157. ( 1 - bounceOut( 1 - 2 * x ) ) / 2 :
  158. ( 1 + bounceOut( 2 * x - 1 ) ) / 2;
  159. }
  160. });
  161. });