Use prefixed requestAnimationFrames if available

This commit is contained in:
Dan Holmsand 2014-01-27 16:26:21 +01:00
parent dfe0eb41d5
commit 4a537af429
1 changed files with 12 additions and 4 deletions

View File

@ -46,10 +46,18 @@
;;; Rendering
(defn next-tick [f]
(if (.-requestAnimationFrame js/window)
(js/requestAnimationFrame f)
(js/setTimeout f 16)))
(defn fake-raf [f]
(js/setTimeout f 16))
(def next-tick
(if-not tmpl/isClient
fake-raf
(let [w js/window]
(or (.-requestAnimationFrame w)
(.-webkitRequestAnimationFrame w)
(.-mozRequestAnimationFrame w)
(.-msRequestAnimationFrame w)
fake-raf))))
(defn compare-levels [c1 c2]
(- (-> c1 js-props (aget cljs-level))