daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest May 17th, 2018 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Effect = (function() {
  2.   var queues = [], active = 0, heart, globalQueue;
  3.  
  4.   function renderQueues() {
  5.     queues.invoke('render', heart.getTimestamp());
  6.   }
  7.  
  8.   function add()    { if (++active == 1) heart.start(); }
  9.   function remove() { if (--active == 0) heart.stop();  }
  10.  
  11.   return {
  12.     initialize: function(heartbeat) {
  13.       globalQueue = new Effect.Queue();
  14.       queues.push(globalQueue);
  15.       heart = heartbeat || new Effect.Heartbeat();
  16.      
  17.       document.observe('effect:heartbeat', renderQueues)
  18.        .observe('effect:queued', add)
  19.        .observe('effect:dequeued', remove);
  20.     },
  21.    
  22.     getTimestamp: function() {
  23.       return heart.getTimestamp();
  24.     },
  25.    
  26.     getGlobalQueue: function() {
  27.       return globalQueue;
  28.     }
  29.   };
  30. }());
RAW Paste Data
Top