summary history branches tags files
commit:08dc0310b873a73e32214bc976e6e4897ec18a77
author:mrmekon
committer:mrmekon
date:Tue Mar 27 12:47:58 2012 -0400
parents:8eb771854ddf1e99788e1820a00d21c3fab1486a
animationFrameMethod cleaned up, and fallback to setInterval works
diff --git a/tempest/tempest.cljs b/tempest/tempest.cljs
line changes: +11/-12
index ad60c15..3f41e88
--- a/tempest/tempest.cljs
+++ b/tempest/tempest.cljs
@@ -849,19 +849,18 @@
           )))
 
 (defn animationFrameMethod []
-  (let [options (list #(.-requestAnimationFrame (dom/getWindow))
-                      #(.-webkitRequestAnimationFrame (dom/getWindow))
-                      #(.-mozRequestAnimationFrame (dom/getWindow))
-                      #(.-oRequestAnimationFrame (dom/getWindow))
-                      #(.-msRequestAnimationFrame (dom/getWindow))
-                      #(.-setInterval (dom/getWindow)))]
+  (let [window (dom/getWindow)
+        options (list (.-requestAnimationFrame window)
+                      (.-webkitRequestAnimationFrame window)
+                      (.-mozRequestAnimationFrame window)
+                      (.-oRequestAnimationFrame window)
+                      (.-msRequestAnimationFrame window))]
     ((fn [[current & remaining]]
-       (if (nil? current)
-         nil
-         (if (fn? (current))
-           (current)
-           (recur remaining)))) options)))
-              
+       (cond
+        (nil? current) #((.-setInterval window) % (/ 1000 60))
+        (fn? current) current
+        :else (recur remaining)))
+     options)))
 
 (def *paused* (atom false))
 

diff --git a/tempest/tempest/macros.clj b/tempest/tempest/macros.clj
line changes: +0/-3
index ad6ec85..eb483ed
--- a/tempest/tempest/macros.clj
+++ b/tempest/tempest/macros.clj
@@ -7,6 +7,3 @@
        (.log js/console
              (str "Fn time: " (pr-str (- (goog.now) starttime#)) " ms")))))
      
-
-(defmacro dofn [& body]
-  `(do ~@body))