module.exports = (type, name, obj) ->
  obj = obj || window
  running = false
  func = ->
    if (running) then return
    running = true
    requestAnimationFrame( ->
      obj.dispatchEvent(new CustomEvent(name))
      running = false
    )
  obj.addEventListener(type, func)