EasingFunction.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. import { Easing } from "@tweenjs/tween.js";
  2. /**
  3. * Easing functions for use with TweenCollection. These function are from
  4. * {@link https://github.com/sole/tween.js/|Tween.js} and Robert Penner. See the
  5. * {@link http://sole.github.io/tween.js/examples/03_graphs.html|Tween.js graphs for each function}.
  6. *
  7. * @namespace
  8. */
  9. const EasingFunction = {
  10. /**
  11. * Linear easing.
  12. *
  13. * @type {EasingFunction.Callback}
  14. * @constant
  15. */
  16. LINEAR_NONE: Easing.Linear.None,
  17. /**
  18. * Quadratic in.
  19. *
  20. * @type {EasingFunction.Callback}
  21. * @constant
  22. */
  23. QUADRATIC_IN: Easing.Quadratic.In,
  24. /**
  25. * Quadratic out.
  26. *
  27. * @type {EasingFunction.Callback}
  28. * @constant
  29. */
  30. QUADRATIC_OUT: Easing.Quadratic.Out,
  31. /**
  32. * Quadratic in then out.
  33. *
  34. * @type {EasingFunction.Callback}
  35. * @constant
  36. */
  37. QUADRATIC_IN_OUT: Easing.Quadratic.InOut,
  38. /**
  39. * Cubic in.
  40. *
  41. * @type {EasingFunction.Callback}
  42. * @constant
  43. */
  44. CUBIC_IN: Easing.Cubic.In,
  45. /**
  46. * Cubic out.
  47. *
  48. * @type {EasingFunction.Callback}
  49. * @constant
  50. */
  51. CUBIC_OUT: Easing.Cubic.Out,
  52. /**
  53. * Cubic in then out.
  54. *
  55. * @type {EasingFunction.Callback}
  56. * @constant
  57. */
  58. CUBIC_IN_OUT: Easing.Cubic.InOut,
  59. /**
  60. * Quartic in.
  61. *
  62. * @type {EasingFunction.Callback}
  63. * @constant
  64. */
  65. QUARTIC_IN: Easing.Quartic.In,
  66. /**
  67. * Quartic out.
  68. *
  69. * @type {EasingFunction.Callback}
  70. * @constant
  71. */
  72. QUARTIC_OUT: Easing.Quartic.Out,
  73. /**
  74. * Quartic in then out.
  75. *
  76. * @type {EasingFunction.Callback}
  77. * @constant
  78. */
  79. QUARTIC_IN_OUT: Easing.Quartic.InOut,
  80. /**
  81. * Quintic in.
  82. *
  83. * @type {EasingFunction.Callback}
  84. * @constant
  85. */
  86. QUINTIC_IN: Easing.Quintic.In,
  87. /**
  88. * Quintic out.
  89. *
  90. * @type {EasingFunction.Callback}
  91. * @constant
  92. */
  93. QUINTIC_OUT: Easing.Quintic.Out,
  94. /**
  95. * Quintic in then out.
  96. *
  97. * @type {EasingFunction.Callback}
  98. * @constant
  99. */
  100. QUINTIC_IN_OUT: Easing.Quintic.InOut,
  101. /**
  102. * Sinusoidal in.
  103. *
  104. * @type {EasingFunction.Callback}
  105. * @constant
  106. */
  107. SINUSOIDAL_IN: Easing.Sinusoidal.In,
  108. /**
  109. * Sinusoidal out.
  110. *
  111. * @type {EasingFunction.Callback}
  112. * @constant
  113. */
  114. SINUSOIDAL_OUT: Easing.Sinusoidal.Out,
  115. /**
  116. * Sinusoidal in then out.
  117. *
  118. * @type {EasingFunction.Callback}
  119. * @constant
  120. */
  121. SINUSOIDAL_IN_OUT: Easing.Sinusoidal.InOut,
  122. /**
  123. * Exponential in.
  124. *
  125. * @type {EasingFunction.Callback}
  126. * @constant
  127. */
  128. EXPONENTIAL_IN: Easing.Exponential.In,
  129. /**
  130. * Exponential out.
  131. *
  132. * @type {EasingFunction.Callback}
  133. * @constant
  134. */
  135. EXPONENTIAL_OUT: Easing.Exponential.Out,
  136. /**
  137. * Exponential in then out.
  138. *
  139. * @type {EasingFunction.Callback}
  140. * @constant
  141. */
  142. EXPONENTIAL_IN_OUT: Easing.Exponential.InOut,
  143. /**
  144. * Circular in.
  145. *
  146. * @type {EasingFunction.Callback}
  147. * @constant
  148. */
  149. CIRCULAR_IN: Easing.Circular.In,
  150. /**
  151. * Circular out.
  152. *
  153. * @type {EasingFunction.Callback}
  154. * @constant
  155. */
  156. CIRCULAR_OUT: Easing.Circular.Out,
  157. /**
  158. * Circular in then out.
  159. *
  160. * @type {EasingFunction.Callback}
  161. * @constant
  162. */
  163. CIRCULAR_IN_OUT: Easing.Circular.InOut,
  164. /**
  165. * Elastic in.
  166. *
  167. * @type {EasingFunction.Callback}
  168. * @constant
  169. */
  170. ELASTIC_IN: Easing.Elastic.In,
  171. /**
  172. * Elastic out.
  173. *
  174. * @type {EasingFunction.Callback}
  175. * @constant
  176. */
  177. ELASTIC_OUT: Easing.Elastic.Out,
  178. /**
  179. * Elastic in then out.
  180. *
  181. * @type {EasingFunction.Callback}
  182. * @constant
  183. */
  184. ELASTIC_IN_OUT: Easing.Elastic.InOut,
  185. /**
  186. * Back in.
  187. *
  188. * @type {EasingFunction.Callback}
  189. * @constant
  190. */
  191. BACK_IN: Easing.Back.In,
  192. /**
  193. * Back out.
  194. *
  195. * @type {EasingFunction.Callback}
  196. * @constant
  197. */
  198. BACK_OUT: Easing.Back.Out,
  199. /**
  200. * Back in then out.
  201. *
  202. * @type {EasingFunction.Callback}
  203. * @constant
  204. */
  205. BACK_IN_OUT: Easing.Back.InOut,
  206. /**
  207. * Bounce in.
  208. *
  209. * @type {EasingFunction.Callback}
  210. * @constant
  211. */
  212. BOUNCE_IN: Easing.Bounce.In,
  213. /**
  214. * Bounce out.
  215. *
  216. * @type {EasingFunction.Callback}
  217. * @constant
  218. */
  219. BOUNCE_OUT: Easing.Bounce.Out,
  220. /**
  221. * Bounce in then out.
  222. *
  223. * @type {EasingFunction.Callback}
  224. * @constant
  225. */
  226. BOUNCE_IN_OUT: Easing.Bounce.InOut,
  227. };
  228. /**
  229. * Function interface for implementing a custom easing function.
  230. * @callback EasingFunction.Callback
  231. * @param {number} time The time in the range <code>[0, 1]</code>.
  232. * @returns {number} The value of the function at the given time.
  233. *
  234. * @example
  235. * function quadraticIn(time) {
  236. * return time * time;
  237. * }
  238. *
  239. * @example
  240. * function quadraticOut(time) {
  241. * return time * (2.0 - time);
  242. * }
  243. */
  244. export default Object.freeze(EasingFunction);