Skip to content

Instantly share code, notes, and snippets.

@rpominov
Created December 21, 2013 20:08
Show Gist options
  • Save rpominov/8074286 to your computer and use it in GitHub Desktop.
Save rpominov/8074286 to your computer and use it in GitHub Desktop.
Bacon.js requestAnimationFrame
Bacon.fromBinder (sink) ->
request =
window.requestAnimationFrame or
window.webkitRequestAnimationFrame or
window.mozRequestAnimationFrame or
window.oRequestAnimationFrame or
window.msRequestAnimationFrame or
(f) -> window.setTimeout(f, 1000 / 60)
subscribed = true
handler = ->
if subscribed
sink()
request handler
request handler
->
subscribed = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment