window.cancelAnimationFrame = window.webkitCancelAnimationFrame = null;
var animationFrame = (function (global) {
var now = performance.now
? performance.now.bind(performance)
: Date.now
? Date.now.bind(Date)
: function(){ return +(new Date()); };
var pendingCallbacks = [];
var pendingHandles = {};
var frameTimer = null;
var lastFrameTime = 0;
function reset_data () {
pendingCallbacks = [];
pendingHandles = {};
frameTimer = null;
}
function object_keys (obj) {
var keys = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
keys.push(key);
}
}
return keys;
}
function generate_handle (currentHandles) {
var handles = object_keys(currentHandles);
var newHandle;
do {
newHandle = Math.round(Math.random() * 4294967296);
} while (handles.indexOf(newHandle) !== -1);
return newHandle;
}
function process_frame () {
var currentCallbacks = pendingCallbacks;
reset_data();
lastFrameTime = now();
for (var i = 0; i < currentCallbacks.length; i++) {
currentCallbacks[i](lastFrameTime);
}
}
function rAF_shim (fn) {
if (typeof fn === 'function') {
if (!frameTimer) {
var delay = Math.max(0, (lastFrameTime + 16) - now());
frameTimer = setTimeout(process_frame, delay);
}
var handle = generate_handle(pendingHandles);
pendingHandles[handle] = fn;
pendingCallbacks.push(fn);
return handle;
}
throw new TypeError("Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.");
}
function cAF_shim (handle) {
var fn = pendingHandles[handle];
var index =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.