From 55e97171cce811b2021a8bde7f6973fac5753a36 Mon Sep 17 00:00:00 2001 From: Jeff Nusz Date: Wed, 17 Aug 2016 16:17:09 -0700 Subject: [PATCH] fix requestAnimationFrame so listen() works --- src/dat/gui/GUI.js | 2 +- src/dat/utils/requestAnimationFrame.js | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index d8eba04..d127e6e 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -1211,7 +1211,7 @@ function setPresetSelectIndex(gui) { function updateDisplays(controllerArray) { if (controllerArray.length !== 0) { - requestAnimationFrame(function() { + requestAnimationFrame.call(window, function() { updateDisplays(controllerArray); }); } diff --git a/src/dat/utils/requestAnimationFrame.js b/src/dat/utils/requestAnimationFrame.js index 147925a..9949e07 100644 --- a/src/dat/utils/requestAnimationFrame.js +++ b/src/dat/utils/requestAnimationFrame.js @@ -11,16 +11,13 @@ * http://www.apache.org/licenses/LICENSE-2.0 */ -export default function() { - function requestAnimationFrame(callback) { - // TODO: Get rid of window - window.setTimeout(callback, 1000 / 60); - } +function requestAnimationFrame(callback) { + setTimeout(callback, 1000 / 60); +} - return window.requestAnimationFrame || +export default window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame; -}