Skip to content

Instantly share code, notes, and snippets.

@IlanFrumer
Last active December 16, 2015 01:59
Show Gist options
  • Save IlanFrumer/5359504 to your computer and use it in GitHub Desktop.
Save IlanFrumer/5359504 to your computer and use it in GitHub Desktop.
window.requestAnimationFrame ||=
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
(callback, element) ->
window.setTimeout( ->
callback(+new Date())
, 1000 / 60)
animate = (func)->
rfunc = ->
func()
requestAnimationFrame(rfunc)
## Example :
a = 1
$ ->
# declate a function:
myFunc = ->
a=1 if a>300
a+=2
$('#pic').css
width:a
# animate it:
animate(myFunc)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment