From 33303bbf627c57b9998ad7e91f80b14b595b37d7 Mon Sep 17 00:00:00 2001 From: e7d Date: Sun, 14 May 2017 14:23:29 +0200 Subject: [PATCH] added a request animation frame polyfill --- js/gamepad.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/gamepad.js b/js/gamepad.js index c1d4f80..bf86e1d 100644 --- a/js/gamepad.js +++ b/js/gamepad.js @@ -1,6 +1,9 @@ class Gamepad { constructor() { this.haveEvents = 'GamepadEvent' in window; + this.rAF = window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || + window.requestAnimationFrame; // cached DOM references this.$gamepad = $('.gamepad'); @@ -288,7 +291,7 @@ class Gamepad { } // enqueue the next refresh right away - requestAnimationFrame(this.updateVisualStatus.bind(this)); + this.rAF(this.updateVisualStatus.bind(this)); // load latest gamepad data this.refreshGamepads();