update request-animation-frame polyfill and add fallback fn
This commit is contained in:
parent
038ab94bc8
commit
5f00b1c9d9
1 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue