API Docs for: 1.7.3
Show:

Rekapi Class

If this is a rendered animation, the appropriate renderer is accessible as this.renderer. If provided, a reference to opt_context is accessible as this.context.

Constructor

Rekapi

(
  • opt_context
)
chainable

Parameters:

  • opt_context Object | CanvasRenderingContext2D | HTMLElement=

    This determines how to render the animation. If this is not provided or is a plain object ({}), the animation will not render anything and this.renderer will be undefined. If this is a reference to a CanvasRenderingContext2D, Rekapi.CanvasRenderer will be initialized as this.renderer for HTML5 canvas-based rendering. This this is a reference to a DOM element, Rekapi.DOMRenderer will be initialized as this.renderer for either a DOM or CSS @keyframe-based rendering.

Methods

addActor

(
  • actor
)
Rekapi.Actor

Add an actor to the animation. Decorates the added actor with a reference to this Rekapi instance as this.rekapi.

Parameters:

  • actor Rekapi.Actor | Object

    If this is an Object, it is used to as the constructor parameters for a new Rekapi.Actor instance that is created by this method.

Returns:

Rekapi.Actor:

The actor that was added.

exportTimeline

() Object

Export the timeline to a JSON-serializable Object.

Example

Returns:

Object:

This data can later be consumed by importTimeline.

getActor

(
  • actorId
)
Rekapi.Actor

Get a reference to an actor from the animation by its id. You can use getActorIds to get a list of IDs for all actors in the animation.

Parameters:

  • actorId Number

Returns:

getActorCount

() Number

Return the number of actors in the animation.

Returns:

Number:

getActorIds

() Array(number)

Retrieve the id's of all actors in an animation.

Returns:

Array(number):

getAllActors

() Object

Retrieve all actors in the animation as an Object.

Returns:

Object:

The keys of this Object correspond to the Actors' ids.

getAnimationLength

() Number

Returns:

Number:

The length of the animation timeline, in milliseconds.

getEventNames

()

Get a list of event names that this Rekapi instance supports.

Returns:

Array(string)

getLastMillisecondUpdated

() Number

Returns:

Number:

The millisecond that was last rendered.

getLastPositionUpdated

() Number

Returns:

Number:

The normalized timeline position (between 0 and 1) that was last rendered.

importTimeline

(
  • rekapiData
)

Import data that was created by exportTimeline. This sets up all actors, keyframes, and custom easing curves specified in the rekapiData parameter. These two methods collectively allow you serialize an animation (for sending to a server for persistence, for example) and later recreating an identical animation.

Parameters:

  • rekapiData Object

    Any object that has the same data format as the object generated from Rekapi#exportTimeline.

isPaused

() Boolean

Returns:

Boolean:

Whether or not the animation is paused (meaning not playing or stopped).

isPlaying

() Boolean

Returns:

Boolean:

Whether or not the animation is playing (meaning not paused or stopped).

isStopped

() Boolean

Returns:

Boolean:

Whether or not the animation is stopped (meaning not playing or paused).

off

(
  • eventName
  • opt_handler
)
chainable

Unbind one or more handlers from a Rekapi event.

Example

Parameters:

  • eventName String

    Valid values correspond to the list under on.

  • opt_handler Function=

    If omitted, all handler functions bound to eventName are unbound.

on

(
  • eventName
  • handler
)
chainable

Bind a handler function to a Rekapi event.

Example

Parameters:

  • eventName String

    Valid values are:

    • animationComplete: Fires when all animation loops have completed.
    • playStateChange: Fires when the animation is played, paused, or stopped.
    • play: Fires when the animation is played.
    • pause: Fires when the animation is paused.
    • stop: Fires when the animation is stopped.
    • beforeUpdate: Fires each frame before all actors are rendered.
    • afterUpdate: Fires each frame after all actors are rendered.
    • addActor: Fires when an actor is added. opt_data is the Rekapi.Actor that was added.
    • removeActor: Fires when an actor is removed. opt_data is the Rekapi.Actor that was removed.
    • beforeAddKeyframeProperty: Fires just before the point where a Rekapi.KeyframeProperty is added to the timeline. This event is called before any modifications to the timeline are done.
    • addKeyframeProperty: Fires when a keyframe property is added. opt_data is the Rekapi.KeyframeProperty that was added.
    • beforeRemoveKeyframeProperty: Fires just before the point where a Rekapi.KeyframeProperty is removed. This event is called before any modifications to the timeline are done.
    • removeKeyframeProperty: Fires when a Rekapi.KeyframeProperty is removed. This event is fired before the internal state of the keyframe (but not the timeline, in contrast to the beforeRemoveKeyframeProperty event) has been updated to reflect the keyframe property removal (this is in contrast to removeKeyframePropertyComplete). opt_data is the Rekapi.KeyframeProperty that was removed.
    • removeKeyframePropertyComplete: Fires when a Rekapi.KeyframeProperty has finished being removed from the timeline. Unlike removeKeyframeProperty, this is fired after the internal state of Rekapi has been updated to reflect the removal of the keyframe property. opt_data is the Rekapi.KeyframeProperty that was removed.
    • addKeyframePropertyTrack: Fires when the a keyframe is added to an actor that creates a new keyframe property track. opt_data is the Rekapi.KeyframeProperty that was added to create the property track. A reference to the actor that the keyframe property is associated with can be accessed via opt_data.actor and the track name that was added can be determined via opt_data.name.
    • removeKeyframePropertyTrack: Fires when the last keyframe property in an actor's keyframe property track is removed. Rekapi automatically removes property tracks when they are emptied out, which causes this event to be fired. opt_data is the name of the track that was removed.
    • timelineModified: Fires when a keyframe is added, modified or removed.
    • animationLooped: Fires when an animation loop ends and a new one begins.
  • handler Function(Rekapi,Object=)

    Receives the Rekapi instance as the first parameter and event-specific data as the second (opt_data).

pause

(
  • pause
)
chainable

Pause the animation. A "paused" animation can be resumed from where it left off with play.

Example

Parameters:

  • pause Object

play

(
  • opt_howManyTimes
)
chainable

Play the animation.

Example

Parameters:

  • opt_howManyTimes Number=

    If omitted, the animation will loop endlessly.

playFrom

(
  • millisecond
  • opt_howManyTimes
)
chainable

Move to a specific millisecond on the timeline and play from there.

Example

Parameters:

  • millisecond Number
  • opt_howManyTimes Number=

    Works as it does in play.

playFromCurrent

(
  • opt_howManyTimes
)
chainable

Play from the last frame that was rendered with update.

Example

Parameters:

  • opt_howManyTimes Number=

    Works as it does in play.

removeActor

(
  • actor
)
Rekapi.Actor

Remove an actor from the animation. This does not destroy the actor, it only removes the link between it and the Rekapi instance. This method calls the actor's teardown method, if it is defined.

Parameters:

Returns:

removeAllActors

() Array.

Remove all actors from the animation.

Returns:

Array.:

stop

() chainable

Stop the animation. A "stopped" animation will start from the beginning if play is called.

Example

trigger

(
  • eventName
  • opt_data
)
chainable

Manually fire a Rekapi event, thereby calling all bound event handlers.

Parameters:

  • eventName String

    The name of the event to trigger.

  • opt_data Any=

    Optional data to provide to eventName handlers.

update

(
  • opt_millisecond
  • opt_doResetLaterFnKeyframes
)
chainable

Render an animation frame at a specific point in the timeline.

Example

Parameters:

  • opt_millisecond Number=

    The point in the timeline at which to render. If omitted, this renders the last millisecond that was rendered (it's a re-render).

  • opt_doResetLaterFnKeyframes Boolean=

    If true, allow all function keyframes later in the timeline to be run again. This is a low-level feature, it should not be true (or even provided) for most use cases.

Properties

nonCustomFormulaNames

Array. static

A list of formulas attached to Tweenable.prototype.formula at startup. This is needed by importTimeline and exportTimeline to handle custom curves created by Tweenable.setBezierFunction.