From 47992755e284fc9c124ea34a7270f3317fc1c0b5 Mon Sep 17 00:00:00 2001 From: Uwe Oestermeier Date: Thu, 20 Jul 2023 14:50:48 +0200 Subject: [PATCH] Replaced requestAnimationFrame with setInterval --- lib/scatter.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/scatter.js b/lib/scatter.js index 23a0242..91cc2b3 100644 --- a/lib/scatter.js +++ b/lib/scatter.js @@ -89,20 +89,19 @@ export class ResizeEvent extends BaseEvent { * @constructor */ -let ThrowableObjects = [] +let ThrowableObjects = new Set() let ThrowableRequests = null function stepThrowAnimation() { let clones = [...ThrowableObjects] - ThrowableObjects = [] + ThrowableObjects.clear() for(let obj of clones) { obj.animateThrow() } - requestAnimationFrame(stepThrowAnimation) } function startThrowableLoop() { - requestAnimationFrame(stepThrowAnimation) + setInterval(stepThrowAnimation, 33) return true } @@ -200,7 +199,7 @@ class Throwable { } recurseAnimateThrow() { - ThrowableObjects.push(this) + ThrowableObjects.add(this) if (ThrowableRequests == null) { ThrowableRequests = startThrowableLoop() }