added a request animation frame polyfill

This commit is contained in:
e7d 2017-05-14 14:23:29 +02:00
parent 590b2708b6
commit 33303bbf62

View File

@ -1,6 +1,9 @@
class Gamepad { class Gamepad {
constructor() { constructor() {
this.haveEvents = 'GamepadEvent' in window; this.haveEvents = 'GamepadEvent' in window;
this.rAF = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.requestAnimationFrame;
// cached DOM references // cached DOM references
this.$gamepad = $('.gamepad'); this.$gamepad = $('.gamepad');
@ -288,7 +291,7 @@ class Gamepad {
} }
// enqueue the next refresh right away // enqueue the next refresh right away
requestAnimationFrame(this.updateVisualStatus.bind(this)); this.rAF(this.updateVisualStatus.bind(this));
// load latest gamepad data // load latest gamepad data
this.refreshGamepads(); this.refreshGamepads();