ded / morpheus

A Brilliant Animator
504 stars 57 forks source link

IE10 requestAnimationFrame #31

Closed ghost closed 11 years ago

ghost commented 11 years ago

requestAnimationFrame in IE work differently, according to MSDN example callback should receive timestamp, but it doesn't. some different number is being passed. i dunno what does it mean.

so here is the simple patch that passes Date.now() instead for IE:

--- a/morpheus.js   2012-10-23 13:37:18.680384028 +0300
+++ b/morpheus.js   2012-10-23 13:33:20.934633400 +0300
@@ -63,15 +63,19 @@
         function (el, property) {
           return el.style[camelize(property)]
         }
+    , ieraf = win.msRequestAnimationFrame &&
+        function (callback) {
+           win.msRequestAnimationFrame(function () { callback(+new Date()) })
+        }
     , frame = function () {
         // native animation frames
         // http://webstuff.nfshost.com/anim-timing/Overview.html
         // http://dev.chromium.org/developers/design-documents/requestanimationframe-implementation
-        return win.requestAnimationFrame  ||
+        return ieraf                      ||
+          win.requestAnimationFrame       ||
           win.webkitRequestAnimationFrame ||
           win.mozRequestAnimationFrame    ||
           win.oRequestAnimationFrame      ||
-          win.msRequestAnimationFrame     ||
           function (callback) {
             win.setTimeout(function () {
               callback(+new Date())
Sirlon commented 11 years ago

Thanks! Your patch fixed my hypnotic looping issue with ie10.

ded commented 11 years ago

@d1o could you submit this back as a pull request? they're real simple to do

ghost commented 11 years ago

done