main.js

  1. /**
  2. * @namespace rekapi
  3. */
  4. /**
  5. * Either the name of an [easing
  6. * curve](https://jeremyckahn.github.io/shifty/doc/Tweenable.html#.formulas) or
  7. * an array of four `number`s (`[x1, y1, x2, y2]`) that represent the points of
  8. * a [Bezier curve](https://cubic-bezier.com/).
  9. * @typedef rekapi.easingOption
  10. * @type {string|Array.<number>}
  11. * @see {@link https://jeremyckahn.github.io/shifty/doc/tutorial-easing-function-in-depth.html}
  12. */
  13. /**
  14. * An Object that provides utilities for rendering a {@link rekapi.Actor}.
  15. * @typedef {Object} rekapi.renderer
  16. * @property {rekapi.render} render A function that renders a {@link
  17. * rekapi.Actor}.
  18. */
  19. /**
  20. * @typedef {Object} rekapi.propertyData
  21. * @property {number|string} value
  22. * @property {number} millisecond
  23. * @property {string} easing
  24. * @property {string} name
  25. * @property {string|undefined} id
  26. */
  27. /**
  28. * @typedef {Object} rekapi.actorData
  29. * @property {Array.<string>} trackNames The values of this array must
  30. * correspond 1:1 to the key names in `propertyTracks`.
  31. * @property {Object.<Array.<rekapi.propertyData>>} propertyTracks
  32. * @property {number} end
  33. * @property {number} start
  34. * @property {string|undefined} id
  35. */
  36. /**
  37. * The properties of this object are used as arguments provided to
  38. * [`shifty.setBezierFunction`](http://jeremyckahn.github.io/shifty/doc/shifty.html#.setBezierFunction).
  39. * @typedef {Object} rekapi.curveData
  40. * @property {number} x1
  41. * @property {number} x2
  42. * @property {number} y1
  43. * @property {number} y2
  44. * @property {string} displayName
  45. */
  46. /**
  47. * The `JSON.stringify`-friendly data format for serializing a Rekapi
  48. * animation.
  49. * @typedef {Object} rekapi.timelineData
  50. * @property {Array.<rekapi.actorData>} actors
  51. * @property {Object.<rekapi.curveData>} curves
  52. * @property {number} duration
  53. */
  54. /**
  55. * A function that is called when an event is fired. See the events listed
  56. * below for details on the types of events that Rekapi supports.
  57. * @callback rekapi.eventHandler
  58. * @param {rekapi.Rekapi} rekapi A {@link rekapi.Rekapi} instance.
  59. * @param {Object} data Data provided from the event (see {@link
  60. * rekapi.Rekapi#on} for details).
  61. */
  62. /**
  63. * A function that gets called every time the actor's state is updated (once
  64. * every frame). This function should do something meaningful with the state of
  65. * the actor (for example, visually rendering to the screen).
  66. * @callback rekapi.render
  67. * @param {Object} context An actor's {@link rekapi.Actor#context} Object.
  68. * @param {Object} state An actor's current state properties.
  69. */
  70. /**
  71. * @callback rekapi.keyframeFunction
  72. * @param {rekapi.Actor} actor The {@link rekapi.Actor} to which this
  73. * {@link rekapi.keyframeFunction} was provided.
  74. * @param {number} drift A number that represents the delay between when the
  75. * function is called and when it was scheduled. There is typically some amount
  76. * of delay due to the nature of JavaScript timers.
  77. */
  78. /**
  79. * @callback rekapi.actorSortFunction
  80. * @param {rekapi.Actor} actor A {@link rekapi.Actor} that should expose a
  81. * `number` value to sort by.
  82. * @return {number}
  83. */
  84. /**
  85. * Fires when all animation loops have completed.
  86. * @event rekapi.animationComplete
  87. */
  88. /**
  89. * Fires when the animation is played, paused, or stopped.
  90. * @event rekapi.playStateChange
  91. */
  92. /**
  93. * Fires when the animation is {@link rekapi.Rekapi#play}ed.
  94. * @event rekapi.play
  95. */
  96. /**
  97. * Fires when the animation is {@link rekapi.Rekapi#pause}d.
  98. * @event rekapi.pause
  99. */
  100. /**
  101. * Fires when the animation is {@link rekapi.Rekapi#stop}ped.
  102. * @event rekapi.stop
  103. */
  104. /**
  105. * Fires each frame before all actors are rendered.
  106. * @event rekapi.beforeUpdate
  107. */
  108. /**
  109. * Fires each frame after all actors are rendered.
  110. * @event rekapi.afterUpdate
  111. */
  112. /**
  113. * @event rekapi.addActor
  114. * @param {rekapi.Actor} actor The {@link rekapi.Actor} that was added.
  115. */
  116. /**
  117. * @event rekapi.removeActor
  118. * @param {rekapi.Actor} actor The {@link rekapi.Actor} that was removed.
  119. */
  120. /**
  121. * Fires just before the point where a {@link rekapi.KeyframeProperty} is added
  122. * to the timeline. This event is called before any modifications to the
  123. * timeline are done.
  124. * @event rekapi.beforeAddKeyframeProperty
  125. */
  126. /**
  127. * @event rekapi.addKeyframeProperty
  128. * @param {rekapi.KeyframeProperty} keyframeProperty The {@link
  129. * rekapi.KeyframeProperty} that was added.
  130. */
  131. /**
  132. * Fires just before the point where a {@link rekapi.KeyframeProperty} is
  133. * removed. This event is called before any modifications to the timeline are
  134. * done.
  135. * @event rekapi.beforeRemoveKeyframeProperty
  136. */
  137. /**
  138. * Fires when a {@link rekapi.KeyframeProperty} is removed. This event is
  139. * fired _before_ the internal state of the keyframe (but not the timeline, in
  140. * contrast to {@link rekapi.event:beforeRemoveKeyframeProperty}) has been
  141. * updated to reflect the keyframe property removal (this is in contrast to
  142. * {@link rekapi.event:removeKeyframePropertyComplete}).
  143. * @event rekapi.removeKeyframeProperty
  144. * @param {rekapi.KeyframeProperty} keyframeProperty The {@link
  145. * rekapi.KeyframeProperty} that was removed.
  146. */
  147. /**
  148. * Fires when a {@link rekapi.KeyframeProperty} has finished being removed from
  149. * the timeline. Unlike {@link rekapi.event:removeKeyframeProperty}, this is
  150. * fired _after_ the internal state of Rekapi has been updated to reflect the
  151. * removal of the keyframe property.
  152. * @event rekapi.removeKeyframePropertyComplete
  153. * @param {rekapi.KeyframeProperty} keyframeProperty The {@link
  154. * rekapi.KeyframeProperty} that was removed.
  155. */
  156. /**
  157. * Fires when the a keyframe is added to an actor that creates a new keyframe
  158. * property track.
  159. * @event rekapi.addKeyframePropertyTrack
  160. * @param {rekapi.KeyframeProperty} keyframeProperty The {@link
  161. * rekapi.KeyframeProperty} that was added to create the property track.
  162. */
  163. /**
  164. * Fires when the last keyframe property in an actor's keyframe property track
  165. * is removed. Rekapi automatically removes property tracks when they are
  166. * emptied out, which causes this event to be fired.
  167. * @event rekapi.removeKeyframePropertyTrack
  168. * @param {string} trackName name of the track that was removed.
  169. */
  170. /**
  171. * Fires when a keyframe is added, modified or removed.
  172. * @event rekapi.timelineModified
  173. */
  174. /**
  175. * Fires when an animation loop ends and a new one begins.
  176. * @event rekapi.animationLooped
  177. */
  178. export { Rekapi } from './rekapi';
  179. export { Actor } from './actor';
  180. export { KeyframeProperty } from './keyframe-property';
  181. export { CanvasRenderer } from './renderers/canvas';
  182. export { DOMRenderer } from './renderers/dom';