aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-12-18 15:54:05 -0500
committerGitHub <noreply@github.com>2020-12-18 15:54:05 -0500
commit51223abfa696c5917828fdb5a6d7b1816d76c5c6 (patch)
tree1c64ad6b15b0773908669cdce14e6d1f319e428e /ext/mixed
parentfd91a5b383addb1b420fba0450a89ceb50cdd3e8 (diff)
Set up initial manifest v3 support (#605)
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/core.js9
1 files changed, 8 insertions, 1 deletions
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);