madrobby (owner)

Revisions

gist: 34305 Download_button fork
public
Public Clone URL: git://gist.github.com/34305.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var s2 = {
  Version: '2.0.0a1'
};
 
s2.fx = new (function(){
  var queues = [], globalQueue, heartbeat, activeEffectCount = 0;
  
  this.beatOnDemand = function(dir){
    heartbeat[(activeEffectCount += dir) > 0 ? 'start' : 'stop']();
  };
  
  this.renderQueues = function(){
    queues.invoke('render', heartbeat.getTimestamp());
  };
  
  this.getQueues = function(){
    return queues;
  };
  
  this.addQueue = function(queue){
    queues.push(queue);
  };
  
  queues.push(globalQueue = new Scripty2.Effect.Queue());
  heartbeat = new Scripty2.Effect.Heartbeat();
  
  document
    .observe('effect:heartbeat', this.renderQueues)
    .observe('effect:queued', this.beatOnDemand.curry(1))
    .observe('effect:dequeued', this.beatOnDemand.curry(-1));
})();