Merge remote-tracking branch 'upstream/master' into rgbcolor_change
[dygraphs.git] / dygraph-utils.js
index 10a393c..086d8f8 100644 (file)
@@ -816,6 +816,8 @@ Dygraph.createIterator = function(array, start, length, opt_predicate) {
 
 // Shim layer with setTimeout fallback.
 // From: http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+// Should be called with the window context:
+//   Dygraph.requestAnimFrame.call(window, function() {})
 Dygraph.requestAnimFrame = (function(){
   return window.requestAnimationFrame       ||
           window.webkitRequestAnimationFrame ||
@@ -854,7 +856,7 @@ Dygraph.repeatAndCleanup = function(repeatFn, maxFrames, framePeriodInMillis,
 
   (function loop() {
     if (frameNumber >= maxFrames) return;
-    Dygraph.requestAnimFrame(function() {
+    Dygraph.requestAnimFrame.call(window, function() {
       // Determine which frame to draw based on the delay so far.  Will skip
       // frames if necessary.
       var currentTime = new Date().getTime();