diff --git a/src/clojure/freactive/dom.cljs b/src/clojure/freactive/dom.cljs index 6210546..90509b3 100644 --- a/src/clojure/freactive/dom.cljs +++ b/src/clojure/freactive/dom.cljs @@ -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