scripty2

class S2.FX.Heartbeat

Description

The heartbeat class provides for effects timing. An instance of this class is automatically created when the first effect on a page is instantiated.

This class can be extended and replaced by your own implementation:

// call before effects are created
var myHeartbeat = Class.create(S2.FX.Heartbeat, { ... });
S2.FX.initialize(new myHeartbeat());

This can be used to implement customized debugging and more.

Constructor

new S2.FX.Heartbeat([options])
  • options (Object) – options hash

The following options are available: * framerate: set (maximum) framerate for calls to S2.FX.beat/

Instance methods

  • beat #

    S2.FX.Heartbeat#beat() -> undefined

    This method fires an effect:heartbeat event which is in turn used by S2.FX to render all active effect queues.

    Fires: effect:heartbeat

  • generateTimestamp #

    S2.FX.Heartbeat#generateTimestamp() -> Date

    Returns the current date and time.

  • getTimestamp #

    S2.FX.Heartbeat#getTimestamp() -> Date

    Returns the current timestamp.

  • start #

    S2.FX.Heartbeat#start() -> undefined

    This function is called by S2.FX whenever there's a new active effect queued and there are no other effects running. This mechanism can be used to prevent unnecessary timeouts/intervals from being active, as S2.FX.Hearbeat.beat is only called when there are active effects that need to be rendered.

  • stop #

    S2.FX.Heartbeat#stop() -> undefined

    Called when the last active effect is dequeued.

  • updateTimestamp #

    S2.FX.Heartbeat#updateTimestamp() -> undefined

    Updates the current timestamp (sets it to the current date and time).

    If subclassed, this can be used to achieve special effects, for example all effects could be sped up or slowed down.