// Shim layer with setTimeout fallback.
// From: http://paulirish.com/2011/requestanimationframe-for-smart-animating/
-Dygraph.requestAnimFrame = (function(){
+// Should be called with the window context:
+// Dygraph.requestAnimFrame.call(window, function() {})
+Dygraph.requestAnimFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
* @private
*/
Dygraph.repeatAndCleanup = function(repeatFn, maxFrames, framePeriodInMillis,
- cleanupFn) {
+ cleanupFn) {
var frameNumber = 0;
var previousFrameNumber;
var startTime = new Date().getTime();
(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();
repeatFn(maxFrameArg); // Ensure final call with maxFrameArg.
cleanupFn();
} else {
- if (frameDelta != 0) { // Don't call repeatFn with duplicate frames.
+ if (frameDelta !== 0) { // Don't call repeatFn with duplicate frames.
repeatFn(frameNumber);
}
loop();
delta = delta || Math.PI * 2 / sides;
ctx.beginPath();
- var first = true;
var initialAngle = rotationRadians;
var angle = initialAngle;