From bf2baaa258b99e93b96ac7fadaa638993fb492fd Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 29 May 2020 21:48:15 -0600 Subject: [PATCH] fix: raf --- src/utils/Raf.js | 17 +++++++++-------- stats.html | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/utils/Raf.js b/src/utils/Raf.js index f4a280ee..e00dcfef 100644 --- a/src/utils/Raf.js +++ b/src/utils/Raf.js @@ -1,5 +1,6 @@ -var now = require('performance-now'), - root = typeof window === 'undefined' ? global : window, +import now from 'performance-now' + +var root = typeof window === 'undefined' ? global : window, vendors = ['moz', 'webkit'], suffix = 'AnimationFrame', raf = root['request' + suffix], @@ -19,12 +20,12 @@ if (!raf || !caf) { queue = [], frameDuration = 1000 / 60 - raf = function(callback) { + raf = function (callback) { if (queue.length === 0) { var _now = now(), next = Math.max(0, frameDuration - (_now - last)) last = next + _now - setTimeout(function() { + setTimeout(function () { var cp = queue.slice(0) // Clear queue here to prevent // callbacks from appending listeners @@ -35,7 +36,7 @@ if (!raf || !caf) { try { cp[i].callback(last) } catch (e) { - setTimeout(function() { + setTimeout(function () { throw e }, 0) } @@ -51,7 +52,7 @@ if (!raf || !caf) { return id } - caf = function(handle) { + caf = function (handle) { for (var i = 0; i < queue.length; i++) { if (queue[i].handle === handle) { queue[i].cancelled = true @@ -67,11 +68,11 @@ export default function Raf(fn) { return raf.call(root, fn) } -Raf.cancel = function() { +Raf.cancel = function () { caf.apply(root, arguments) } -Raf.polyfill = function(object) { +Raf.polyfill = function (object) { if (!object) { object = root } diff --git a/stats.html b/stats.html index 913e3e77..aaba5be2 100644 --- a/stats.html +++ b/stats.html @@ -2638,7 +2638,7 @@