update request-animation-frame polyfill and add fallback fn

This commit is contained in:
Karsten Schmidt 2014-11-22 14:12:01 +00:00
parent 038ab94bc8
commit 5f00b1c9d9

View file

@ -171,8 +171,19 @@
;; ## Polyfills
(defn request-animation-frame [f]
(.requestAnimationFrame js/window f))
(def ^:private raf-start-time (.getTime (js/Date.)))
(def request-animation-frame
(or
(.-requestAnimationFrame js/window)
(.-webkitRequestAnimationFrame js/window)
(.-mozRequestAnimationFrame js/window)
(.-msRequestAnimationFrame js/window)
(.-oRequestAnimationFrame js/window)
(fn [f]
(js/setTimeout
#(f (- (.getTime (js/Date.)) raf-start-time))
16.66666))))
;; Render Loop