From 51223abfa696c5917828fdb5a6d7b1816d76c5c6 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 18 Dec 2020 15:54:05 -0500 Subject: Set up initial manifest v3 support (#605) --- ext/mixed/js/core.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ext/mixed') diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index 72ab7474..aa894e01 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -304,7 +304,12 @@ function promiseTimeout(delay, resolveValue) { } function promiseAnimationFrame(timeout=null) { - return new Promise((resolve) => { + return new Promise((resolve, reject) => { + if (typeof cancelAnimationFrame !== 'function' || typeof requestAnimationFrame !== 'function') { + reject(new Error('Animation not supported in this context')); + return; + } + let timer = null; let frameRequest = null; const onFrame = (time) => { @@ -318,12 +323,14 @@ function promiseAnimationFrame(timeout=null) { const onTimeout = () => { timer = null; if (frameRequest !== null) { + // eslint-disable-next-line no-undef cancelAnimationFrame(frameRequest); frameRequest = null; } resolve({time: timeout, timeout: true}); }; + // eslint-disable-next-line no-undef frameRequest = requestAnimationFrame(onFrame); if (typeof timeout === 'number') { timer = setTimeout(onTimeout, timeout); -- cgit v1.2.3