Guest User

Untitled

a guest
Apr 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. var Effect = {
  2. initialize: function(heartbeat) {
  3. if (this.heartbeat) return;
  4.  
  5. this.queues = [];
  6. this.globalQueue = new Effect.Queue();
  7. this.queues.push(this.globalQueue);
  8.  
  9. this.heartbeat = heartbeat || new Effect.Heartbeat();
  10. this.activeEffectCount = 0;
  11.  
  12. document
  13. .observe('effect:heartbeat', this.renderQueues.bind(this))
  14. .observe('effect:queued', this.beatOnDemand.bind(this, 1))
  15. .observe('effect:dequeued', this.beatOnDemand.bind(this, -1));
  16. },
  17.  
  18. beatOnDemand: function(dir) {
  19. this.heartbeat[(this.activeEffectCount += dir) > 0 ? 'start' : 'stop']();
  20. },
  21.  
  22. renderQueues: function() {
  23. this.queues.invoke('render', this.heartbeat.getTimestamp());
  24. }
  25. };
Add Comment
Please, Sign In to add comment